Author Ben.Darnell
Recipients Ben.Darnell, Big Stone, asvetlov, lukasz.langa, vstinner, yselivanov
Date 2019-06-22.22:05:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561241104.05.0.743639637265.issue37373@roundup.psfhosted.org>
In-reply-to
Content
> From my understanding, there is no issue for Tornado itself. If Jupiter Notebook needs Tornado, Tornado needs selector event loop on Windows -- Jupiter can install the proper loop.

Right. I'm just advocating for something that would make the transition smoother than each project independently stumbling across this issue and adding their own patch (and then fielding support issues from users who have ended up with a combination of versions that doesn't quite work). This of course depends on how many affected projects there are; I know Jupyter is the biggest but they're not the only one. 

There's no more direct way, but a thread that does select() should work. In fact, ProactorEventLoop could simply spin up a SelectorEventLoop in another thread when one of the FD methods is called, and proxy the callbacks back and forth. 

    def add_reader(self, fd, callback, *args):
        if not self.selector_started:
            self.start_selector()
        self.selector.call_soon(self.selector.add_reader, fd, lambda: self.call_soon(callback, *args))

    def start_selector(self):
        self.selector = SelectorEventLoop()
        def target():
            asyncio.set_event_loop(self.selector)
            self.selector.run_forever()
        thread = threading.Thread(target=target)
        thread.start()
        # Clean shutdown is left as an exercise for the reader.

Unifying the two interfaces like this would be preferable to adding more complexity for configuration IMHO.
History
Date User Action Args
2019-06-22 22:05:04Ben.Darnellsetrecipients: + Ben.Darnell, vstinner, asvetlov, lukasz.langa, yselivanov, Big Stone
2019-06-22 22:05:04Ben.Darnellsetmessageid: <1561241104.05.0.743639637265.issue37373@roundup.psfhosted.org>
2019-06-22 22:05:04Ben.Darnelllinkissue37373 messages
2019-06-22 22:05:03Ben.Darnellcreate