-
Notifications
You must be signed in to change notification settings - Fork 5.5k
asyncio: Improve support Python 3.8 on Windows #2815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
As a Jupyter maintainer, I'd love to see this in a release, so anything I can do to help it along, let me know. I opened bdarnell#2 against this branch, which gets things passing for me on non-Windows, but it looks like there are still a couple thread-related kinks when this actually gets used. We've been pretty slow to roll out the application-level workaround for #2804 because we have so many applications. I think your points about this being a pain at the application level and not having a good library-level solution are being borne out. Notebook itself and ipykernel were fixed relatively promptly, but there are still stragglers like QtConsole, and there isn't a good way for us in Jupyter to have a single global fix that wouldn't have the same problems as tornado itself setting the event loop at import/start/etc. |
The set_wakeup_fd error ( |
Another test failure is in ioloop test The test failure is because the When a read event fires:
The |
Excellent, thanks for jumping in and testing! That Other partial solutions include
I think we need to control the select loop itself instead of just using the SelectorEventLoop black box API. This probably means writing directly to the lower-level |
I think it makes sense since it’s a race - sometimes main will process the event before selector’s next tick, in which case it’ll pass, sometimes it won’t. It fails less than half of the time for me, but pretty often still. I saw everywhere from 0 to 7 extra events when I added some prints to debug it. The delay I added wasn’t a generic sleep to help win the race more often; a future is used to prevent duplicate calls to the “real” callback, while duplicate firing in the selector results in a sleep until the “real” callback finishes firing. I’m only working part time, so it’s a bit of a flyby contribution, but if you haven’t had a chance by the time I get some time next week, I’ll look at the select approach. |
71ba9e3
to
0304c8c
Compare
c0a4fc9
to
c789c43
Compare
I've reworked this to fix the race; all the tests are now passing on windows. It's still failing in CI, but only because there's a bunch of log spam. Most of that is coming from asyncio itself so I may just have to disable the log checks on windows. @minrk If you'd like to take another look, pay attention to the issues behind #2719. That test needed some tweaking and I'm not entirely sure whether the test was at fault or if the bug is resurfacing with the new event loop. |
0a0b7e3
to
eebd582
Compare
fc05303
to
244888e
Compare
Without this try/finally, if this test ever fails, errors can be reported in a confusing way.
Closing the file descriptor without removing the corresponding handler is technically incorrect, although the default IOLoops don't have a problem with it.
This commit removes the need for applications to work around the backwards-incompatible change to the default event loop. Instead, Tornado will detect the use of the windows proactor event loop and start a selector event loop in a separate thread. Closes tornadoweb#2804
Running a whole event loop on the other thread leads to tricky synchronization problems. Instead, keep as much as possible on the main thread, and call out to a second thread only for the blocking select system call itself.
Use this on windows due to a log spam issue in asyncio.
Restarting the event loop to "cleanly" shut down a coroutine introduces other problems (mainly manifesting as errors logged while running tornado.test.gen_test). Replace the coroutine with a pair of callbacks so we don't need to do anything special to shut down without logging warnings.
The just-released version 0.3.0 is incompatible with our older pinned version of sphinx.
244888e
to
9602c6a
Compare
This is getting more or less ready. I've submitted a fix to cpython to eliminate the "self pipe" logging (we'll still need to run without the log assertion until that fix comes out in python 3.8.6). Testing locally with that build I found another unrelated source of log spam which I fixed by moving away from coroutines in the event loop itself (it's hard to shut these things down cleanly when they're a part of the event loop). Now things are looking good except for one failure I just saw on appveyor that I haven't been able to reproduce either locally or retrying on appveyor. It's not completely clear what's going on because appveyor is running python with the log spam issue (and it's just running 3.8.0 instead of 3.8.5, although I don't see anything in the changelog that's obviously relevant). |
Any hope for jupyterlab-3 final ? Around mid october |
Yeah, that should be doable. I've re-run CI a bunch of times without seeing that mysterious failure again, so I'll just chalk it up to a fluke and merge this. Then I think there are just a couple of open PRs I want to evaluate and maybe merge before starting the release process for 6.1. |
This commit removes the need for applications to work around the
backwards-incompatible change to the default event loop. Instead,
Tornado will detect the use of the windows proactor event loop and
start a selector event loop in a separate thread.
Closes #2804