File "/home/server_trunk/test/server/db/client.py", line 40, in _call_in_tornadoreturn self.ioloop.run_sync(_coroutine)File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 413, in run_syncself.start()File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 704, in startraise RuntimeError("IOLoop is already running")I have a HTTPServer, and start IOLoop in main.
When I need run_sync some gen.coroutine in web handle, the RuntimeError always be raise.How to handle the error? and What the best pattern of wait coroutine in web handle?
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def call(self, method, *args): @tornado.gen.coroutine def _coroutine(): ret = yield self.call_async(method, *args) raise tornado.gen.Return(ret) return self.ioloop.run_sync(_coroutine)
def call_async(self, method, *args): future = self.client.call_async(method, *args)
return future
class TestHandler(RequestHandler):
@tornado.gen.coroutine
def get(self):
ret = yield call_async('sum',1,2) # it's ok
class TestHandler2(RequestHandler):
def get(self):
ret = call('sum', 1, 2) # it can be implemented ??
tks for your reply.in my app, I use msgpackrpc-python, it has `call` and `call_async` function to implement rpc call.forgive me for obsession. `call_async` work well with tornado's coroutine, but i confused at `call` function how to integrated with coroutine.