Is there a way to run system commands asynchronously? For instance, let's say you're given an image as input, and you'd like to run some image conversion or optimization program in the background. Can you do this without blocking?
web.by fires up a thread; I've done it by using an external worker.
You probably want subprocess.
The better way to handle this is using a message queue. You push a job onto a queue and a worker picks it up and process it. Check out RabbitMQ, pyres, gearman, bealstalkd etc.
+1 for yashh
you can find an example at http://brianglass.wordpress.com/2009/11/29/asynchronous-shell-commands-with-tornado/
The multiprocessing package in Python 2.6 std lib works well with Tornado's IO loop.
I wrote a module for tornado similar to the AsyncHTTPClient just for this purpose.
Is there a way to run a set of mysql queries in parallel. Bret Taylor's post on mysql explains that they query all mysql shards in parallel. Can we do this in tornado ?
Well, you might want to leverage the async_process and pipe the result into tornado.
Put the data (e.g. filename of the image in question) in a queue Q and process that queue in another process. Python comes already with everything you need:
If you want to do that distributed, check out ZeroMQ http://www.zeromq.org
add ###2 for test
Tornado 3.0 introduced tornado.process.Subprocess: http://www.tornadoweb.org/en/stable/process.html#tornado.process.Subprocess