8

What exactly are SelectorEventLoop and ProactorEventLoop? How are they different?

I was testing the use of asyncio and aiohttp in python on Windows, then got an error RuntimeError: Event loop is closed. Looked up and found a workaround, but I did not understand the root of the error.
Many people seem to touch on the concept of SelectorEventLoop and ProactorEventLoop here and also here.

I read documentation but couldn't grasp the concept. Could anyone explain these concept in easier terms?

3
  • 5
    In short: Windows uses I/O Completion Ports for processing multiple async IO operations (not to go in-depth, Windows implements things differently at a "deeper" level (for lack of better words), and to access different IO asynchronously you must use this interface). Therefore, two implementations were made: SelectorEventLoop, which is the default for most platforms (MacOS, Linux, etc.), and ProactorEventLoop, which is the Windows-specific event-loop that is capable of making IO bound calls on Windows machines. Commented Jun 14, 2021 at 3:49
  • 3
    Note that SelectorEventLoop still works on Windows, but only works with sockets, and not pipes. Since pipes are a process communication tool it requires more in-depth kernel-level implementations, and on Windows, it is named "I/O Completion Ports", which is what ProactorEventLoop uses. Commented Jun 14, 2021 at 3:55
  • More details about differences: docs.python.org/3.8/library/asyncio-platforms.html#windows Commented Aug 18, 2022 at 9:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.