Sunday, 15 April 2012

python - using PIL in asynchronous code (Twisted Web) -



python - using PIL in asynchronous code (Twisted Web) -

i have web api receives image, , passes asynchronous service. before passing if farther scale downwards using pil.

my code looks (simplifying, skipping unrelated details):

def render_post(self, request): pil_image = image.open(request.content) pil_image.thumbnail((640,640), image.antialias) outfile = stringio() pil_image.save(outfile, "jpeg") do_something_async_and_write_result(outfile) homecoming not_done_yet

is there way can create asynchronous without over-engineering* it?

*i consider illustration setting message queue service over-engineering

if thread saftey given (concerning pil , how utilize it), utilize defertothread: https://twistedmatrix.com/documents/current/api/twisted.internet.threads.html

enhanced formulation, calderone

python asynchronous twisted python-imaging-library

No comments:

Post a Comment