ItsDrike / CommandBot

Discord Bot which can handle most administrative tasks for servers.
Other
0 stars 0 forks source link

Use selector event loop on windows #24

Closed ItsDrike closed 4 years ago

ItsDrike commented 4 years ago

With the 3.8 python update, the default event loop on windows is now the ProactorEventLoop; one of aiohttp's dependencies uses features which are not supported in this event loop leading to crashes on startup on windows with an undescriptive error

From cffi callback <function _sock_state_cb at 0x0000000003816040>:
Traceback (most recent call last):
  File "C:\Users\test\.virtualenvs\bot-K_QdelnW\lib\site-packages\pycares\__init__.py", line 91, in _sock_state_cb
    sock_state_cb(socket_fd, readable, writable)
  File "C:\Users\test\.virtualenvs\bot-K_QdelnW\lib\site-packages\aiodns\__init__.py", line 105, in _sock_state_cb
    self.loop.add_reader(fd, self._handle_event, fd, READ)
  File "C:\Users\test\AppData\Local\Programs\Python\Python38\Lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

This can be fixed by setting the event loop policy to WindowsSelectorEventLoopPolicy through asyncio.set_event_loop_policy when the platform is detected to be windows