Message393726
> It's even slightly easier for tornado, which can reasonably set the proactor-wrapper policy at IOLoop start time, which means `asyncio.get_event_loop()` returns a loop with add_reader. But pyzmq doesn't get invoked until an event loop is already running.
That's not what I'm doing in Tornado; I don't change the policy or the result of get_event_loop. Instead, I call get_event_loop (only once) and wrap its result in AddThreadSelectorEventLoop. This works even while the event loop is already running (which is not an uncommon case; there is no expectation that you use tornado.ioloop.IOLoop.start instead of asyncio.EventLoop.run_forever).
This relies on the fact that I already have my own thread-local lookup function to retrieve the wrapped event loop; an application that used the more typical asyncio patterns and relied on get_event_loop would indeed have difficulty with this pattern. |
|
Date |
User |
Action |
Args |
2021-05-15 19:32:35 | Ben.Darnell | set | recipients:
+ Ben.Darnell, njs, asvetlov, lukasz.langa, yselivanov, steve.dower, minrk, Big Stone, cmeyer, mikeshardmind, jack1142, carltongibson |
2021-05-15 19:32:35 | Ben.Darnell | set | messageid: <1621107155.22.0.307254554033.issue37373@roundup.psfhosted.org> |
2021-05-15 19:32:35 | Ben.Darnell | link | issue37373 messages |
2021-05-15 19:32:35 | Ben.Darnell | create | |
|