Skip to content
Browse files

Added argument to specify the ioloop in TornadoExecutor's constructor

  • Loading branch information...
1 parent 46ca326 commit 8b0d0c53d57661946e5d4e2f2f2bf06df982547b @jjwchoy committed May 24, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 tornado/futures.py
View
8 tornado/futures.py
@@ -24,16 +24,20 @@ def __call__(self, *args, **kwargs):
class TornadoExecutor(_base.Executor):
- def __init__(self):
+ def __init__(self, ioloop=None):
self._shutdown = False
+ if ioloop is None:
+ self._ioloop = tornado.ioloop.IOLoop.instance()
+ else:
+ self._ioloop = ioloop
def submit(self, fn, *args, **kwargs):
if self._shutdown:
raise RuntimeError('cannot schedule new futures after shutdown')
f = _base.Future()
w = _WorkItem(f, fn, args, kwargs)
- tornado.ioloop.IOLoop.instance().add_callback(w.run)
+ self._ioloop.add_callback(w.run)
return f
def shutdown(self, wait=True):

0 comments on commit 8b0d0c5

Please sign in to comment.
Something went wrong with that request. Please try again.