3 ms·
Do you know of a good resource for learning how to write event loops using these primitives? I feel like there are some extremely common and robust patterns the
by kqr 3y ago
Do you know of a good resource for learning how to write event loops using these primitives? I feel like there are some extremely common and robust patterns there, but my day job mostly involves high-level abstractions like async/await so I never get to dig into how it really works.
- supriyo-biswas 3y agoDavid Beazley’s Python Concurrency from the Ground Up[1] is a great introduction. [1] https://www.youtube.com/watch?v=MCs5OvhV9S4 https://www.youtube.com/watch?v=MCs5OvhV9S4
- dns_snek 3y agoYou might be interested in a pure Zig implementation of these primitives by Mitchell in his "libxev" event loop library: https://github.com/mitchellh/libxev https://github.com/mitchellh/libxev
- yla92 3y agoI am not expert in these but I thought Tornado's ioloop was readable enough for me to learn more event loops. Mostly, it was being implemented in pure Python. https://github.com/tornadoweb/tornado/blob/branch4.5/tornado/ioloop.py#L72 https://github.com/tornadoweb/tornado/blob/branch4.5/tornado... (Had to be in 4.5 because the newer versions 5.x and 6.x, it's switched to Python's stdlib asyncio)
- anonymousDan 3y agoHave a look at how memcached does it. It's a bit more interesting than most examples I've seen as insofar as I can remember it combines epoll with multithreading. Be aware that many of the tutorials and criticisms of epoll are a bit outdated as the API has evolved a little over time.