Skip to content

Tornado 5 fixes and workarounds - #1518

Merged
pitrou merged 1 commit into
dask:masterfrom
pitrou:tornado5_workarounds
Nov 2, 2017
Merged

pitrou merged 1 commit into
dask:masterfrom
pitrou:tornado5_workarounds

Conversation

@pitrou

@pitrou pitrou commented Nov 2, 2017 •

Copy link
Copy Markdown
Member

Most of the test suite seems to pass with this. IPython-related tests fail with some timeouts (perhaps ZMQ doesn't like Tornado 5?).

Comment thread distributed/utils.py
raise gen.Return(results)


def is_loop_running(loop):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, this is not ideal, but gets us running until a decision is made on tornadoweb/tornado#2085

Comment thread distributed/client.py
"""
result = self._asynchronous
try:
if self.loop._thread_ident and get_thread_identity() != self.loop._thread_ident:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That only works if the loop wasn't started by the user.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the same pattern occurs in worker.py below which doesn't have a LoopRunner.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 API

There 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect my replacement code below should work, since self.loop is IOLoop.current() is false if you call it from another thread.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, you're right, that's probably nicer regardless. Thanks!

@pitrou

pitrou commented Nov 2, 2017

Copy link
Copy Markdown
Member Author

I'm going to merge if no further comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants