Author Ben.Darnell
Recipients Ben.Darnell, asvetlov, yselivanov
Date 2019-06-22.18:33:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561228405.39.0.674272094682.issue37373@roundup.psfhosted.org>
In-reply-to
Content
On Windows there are two event loop implementions with different interfaces: The proactor event loop is missing the file descriptor family of methods (add_reader()), while the selector event loop has other limitations including missing support for pipes and subprocesses and generally lower scalability. (The default has changed from selector to proactor in Python 3.8).

If an application requires the selector event loop, it can set the global event loop policy when it starts up. But what if a library requires the selector event loop? It wouldn't be appropriate for a library to set the event loop policy. The best I can do is document that "This library requires an event loop which supports the add_reader() method; to use this library on Windows (directly or indirectly) you must install the WindowsSelectorEventLoopPolicy."  

This places a burden on application developers that target Windows to examine all their transitive dependencies to see if any require selectorevent loops (and if any have conflicting requirements for proactor event loops, which are even less likely to be documented since this is now the default). Concretely, this is a concern for Tornado (which requires add_reader()) and applications in the scientific python community (including Jupyter) which depend on it. 

I know it's probably too late to do anything about this for 3.8, but it would be great if there were some better process to negotiate the right event loop. Some ideas (none of which are very satisfying):
- A declarative marker in setup.cfg or similar indicating the required feature set for an event loop
- A dummy package that could be depended on to indicate the same thing (and maybe this package could even use .pth hacks to change the default simply by being installed, but that seems like a hack too far)
- Some sort of runtime registry: at import time, Tornado could call `asyncio.add_required_features(asyncio.ADD_READER)` and this would influence the default policy
- Flags to `get_event_loop()` indicating the required features (passed through to the policy).
History
Date User Action Args
2019-06-22 18:33:25Ben.Darnellsetrecipients: + Ben.Darnell, asvetlov, yselivanov
2019-06-22 18:33:25Ben.Darnellsetmessageid: <1561228405.39.0.674272094682.issue37373@roundup.psfhosted.org>
2019-06-22 18:33:25Ben.Darnelllinkissue37373 messages
2019-06-22 18:33:24Ben.Darnellcreate