asyncio is an event driven core lib of python 3.4. I know twisted, a similar lib for asyncio, implements the Reactor pattern, but what kind of pattern does asyncio implement?
2 Answers
Well, it uses reactor for posix. Windows implementation has proactor event loop too.
4 Comments
Volodymyr Pavlenko
Are
windows_events.py and unix_events.py good starting points for investigation?Andrew Svetlov
No.
unix_events.py is about signal handling and subprocess execution. windows_events.py is overcomplicated due Windows io completion port nature. As the best starting point I recommend selector_events.py.Marc
@AndrewSvetlov you're referring to this selector_events.py? Would you point out the proactor and reactor patterns in the code that you referred to?
Andrew Svetlov
Reactor pattern is used for every loop implementation except
asyncio.windows_event:ProactorEventLoop obviously.As @AndrewSvetlov answered, Python already will select the most performant selector for you, depending on your operating system. Different selector event loops will be, ensuring to get the tightest loop, the most performant selector available on your operating system. So it implements both patterns.