Skip to content

RuntimeError: aiodns needs a SelectorEventLoop on Windows #21

Closed
@ruidazeng

Description

@ruidazeng

I have been trying to benchmark on my Windows machine today (instead of my usual Macbook), and I ran into these errors when running the program normally (with all the requirements installed).

  File "C:\Users\RAZEER\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiohttp\connector.py", line 845, in __init__
    resolver = DefaultResolver(loop=self._loop)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\RAZEER\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiohttp\resolver.py", line 95, in __init__
    self._resolver = aiodns.DNSResolver(*args, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\RAZEER\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiodns\__init__.py", line 60, in __init__
    raise RuntimeError(
RuntimeError: aiodns needs a SelectorEventLoop on Windows. See more: https://github.com/saghul/aiodns/issues/86

This was fixed by adding this line on top of the code in main.py.

if __name__ == "__main__":
    if hasattr(asyncio, "WindowsSelectorEventLoopPolicy"):
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # Windows handles asynchronous event loops

I am wondering if this is a common issue and if other people has ran into something similar, or if there is some other fixes possible.

I am checking for more issues while running the benchmarks, and will submit a pull request to both the benchmarks branch and the main branch (if needed) at some point later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions