Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError on Windows #86

Closed
oyarsa opened this issue Sep 24, 2020 · 13 comments
Closed

NotImplementedError on Windows #86

oyarsa opened this issue Sep 24, 2020 · 13 comments

Comments

@oyarsa
Copy link

oyarsa commented Sep 24, 2020

I tried running the example code on the README, and got this error:

From cffi callback <function _sock_state_cb at 0x00000240DB1BEC10>:
Traceback (most recent call last):
  File "C:\Users\italo\Google Drive\Code\Projects\email-lists\env\lib\site-packages\pycares\__init__.py", line 91, in _sock_state_cb
    sock_state_cb(socket_fd, readable, writable)
  File "C:\Users\italo\Google Drive\Code\Projects\email-lists\env\lib\site-packages\aiodns\__init__.py", line 104, in _sock_state_cb
    self.loop.add_reader(fd, self._handle_event, fd, READ)
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

The program hung after that. After interrupting it, this is the traceback:

Traceback (most recent call last):
  File "a.py", line 11, in <module>
    result = loop.run_until_complete(coro)
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 570, in run_forever
    self._run_once()
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1823, in _run_once
    event_list = self._selector.select(timeout)
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 430, in select
    self._poll(timeout)
  File "C:\Users\italo\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 779, in _poll
    status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms)
KeyboardInterrupt

This is on Windows 10 build 2004 with Python 3.8.5 and aiodns 2.0.0.

@P0oOOOo0YA
Copy link

Having the same problem on windows. So the workaround would be to run this under WSL.

@abersheeran
Copy link

Same problem in CPython3.9 on windows10.

@joggraphy
Copy link

Exactly the same problem on Python 3.9.4 on Windows 10 using the example program. Any suggestions?

@FredericMa
Copy link

I'm having the same issue.

@BiDuang
Copy link

BiDuang commented Feb 20, 2023

Still got problem on Windows 10 with python3.9.5 and Windows 11 with python 3.10

@saghul
Copy link
Contributor

saghul commented Feb 20, 2023

c-ares, what is used underneath, requires a readyness style API, which is not supported on Windows unless you are using a SelectorEventLoop implementation: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.SelectorEventLoop

@BiDuang
Copy link

BiDuang commented Feb 20, 2023

Okay, thanks. By the way, I made an improvement to let other users know about this issue, and merge it if you think it's good. #105

@g-regor
Copy link

g-regor commented Aug 11, 2023

In user code, it can be solved by adding

if sys.platform == 'win32':
	asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Maybe it should be part of the example?

@saghul
Copy link
Contributor

saghul commented Aug 11, 2023

Oh that's nice! When did they add to Python?

Happy to take a PR if you're up for it!

@g-regor
Copy link

g-regor commented Aug 16, 2023

WindowsSelectorEventLoopPolicy was added in 3.7

In 3.8 the default event loop for windows was changed to ProactorEventLoop. At which point this became necessary.

Seems this was already discussed in #78

saghul added a commit that referenced this issue Oct 7, 2023
@saghul saghul closed this as completed in 7569a4b Oct 7, 2023
tazlin added a commit to Haidra-Org/horde-worker-reGen that referenced this issue Jul 31, 2024
I am unclear on the exact package causing this issue but my guess is that the call (`asyncio.set_event_loop_policy(...)`) either was previously happening elsewhere or is now being overridden somehow in the latest version of a package.

The error that occurs without this fix directs you to aio-libs/aiodns#86 which indicated the fix used in this commit.
tazlin added a commit to Haidra-Org/horde-worker-reGen that referenced this issue Jul 31, 2024
I am unclear on the exact package causing this issue but my guess is that the call (`asyncio.set_event_loop_policy(...)`) either was previously happening elsewhere or is now being overridden somehow in the latest version of a package.

The error that occurs without this fix directs you to aio-libs/aiodns#86 which indicated the fix used in this commit.
KiGamji added a commit to KiGamji/bc-bot that referenced this issue Aug 16, 2024
…>= 3.11

Fixes:
RuntimeError: aiodns needs a SelectorEventLoop on Windows. See more: aio-libs/aiodns#86
K1rL3s added a commit to K1rL3s/aliceio that referenced this issue Sep 4, 2024
В тестах с aiohttp 3.10.0 случается проблема из aio-libs/aiodns#86, но на aiohttp 3.9.5 такого не происходит
tazlin added a commit to Haidra-Org/horde-sdk that referenced this issue Sep 23, 2024
tazlin added a commit to Haidra-Org/horde-sdk that referenced this issue Sep 23, 2024
macmarrum added a commit to macmarrum/radio357 that referenced this issue Sep 24, 2024
macmarrum added a commit to macmarrum/radio357 that referenced this issue Sep 29, 2024
@ruidazeng
Copy link

What does this mean....

  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

@g-regor
Copy link

g-regor commented Oct 27, 2024

What does this mean....

  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

Did you read this thread? Or the README?

@ruidazeng
Copy link

What does this mean....

  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

Did you read this thread? Or the README?

Fixed thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants