Hi Tornadists,
I'm running Tornado 4.1 on Python 2.7, and having trouble with the @run_on_executor decorator. I've written a further decorator that automagically creates an object with the io_loop and executor attributes on it, and it works great when the executor I use is a ThreadPoolExecutor - but I run into pickling errors when I use a ProcessPoolExecutor.
I've cut back my code to a minimal example and posted it on Gist:
If I do a GET on /thread, it works fine; if I hit /process, the request hangs and the Tornado process prints this traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/queues.py", line 266, in _feed
send(obj)
PicklingError: Can't pickle <type 'thread.lock'>: attribute lookup thread.lock failed
If I set up Tornado to use HTTPS, the PicklingError is on ssl.SSLContext instead.
Is there anything I can do about this, or am I stuck using thread pools? Presumably there's something in the @gen.coroutine machinery that doesn't like being pickled here.
Thanks,
-Hussein