Repository navigation
Tornado 5 fixes and workarounds - #1518
Conversation
| raise gen.Return(results) | ||
|
|
||
|
|
||
| def is_loop_running(loop): |
There was a problem hiding this comment.
Of course, this is not ideal, but gets us running until a decision is made on tornadoweb/tornado#2085
| """ | ||
| result = self._asynchronous | ||
| try: | ||
| if self.loop._thread_ident and get_thread_identity() != self.loop._thread_ident: |
There was a problem hiding this comment.
Could this also be handled by the LoopRunner? We could capture the thread of the IOLoop at the same time we wait for the threading.Event
There was a problem hiding this comment.
That only works if the loop wasn't started by the user.
There was a problem hiding this comment.
Also, the same pattern occurs in worker.py below which doesn't have a LoopRunner.
There was a problem hiding this comment.
This code is useful because it allows us to use clients that were created to work asynchronously safely outside of an asynchronous environment.
@gen.coroutine
def f():
client = yield Client(asynchronous=True)
...
client = ... get the same client ...
client.gather(...) # this identifies that it is outside of the IOLoop and uses the blocking APIThere are likely cleaner ways around this, such as by creating multiple clients or asking users to explicitly annotate all calls with asynchronous=True/False. I'm -1 on the second option (users don't understand this). The first option is possible, but would require some work on our part.
There was a problem hiding this comment.
I suspect my replacement code below should work, since self.loop is IOLoop.current() is false if you call it from another thread.
There was a problem hiding this comment.
OK, you're right, that's probably nicer regardless. Thanks!
|
I'm going to merge if no further comments. |
Most of the test suite seems to pass with this. IPython-related tests fail with some timeouts (perhaps ZMQ doesn't like Tornado 5?).