When run on Windows, Sopel appears to hang after asyncio emits the log line, "Using proactor: IocpProactor".
Under the hood, what actually happens here is that the event loop starts, but trying to set up a signal handler (code excerpt below) raises NotImplementedError on Windows and execution stalls.
The error and traceback is logged to configname.exceptions.log.
Reproduction steps
Install Sopel on Windows
Try to run it
Expected behavior
Sopel's signal handling needs a rework to behave at least somewhat correctly cross-platform, even if the Windows code path can't fully support all features offered on Unix-like platforms.
There is probably a way to make everything work, with a bit of "AI" (read: if/else checks). I just haven't looked into it because this whole thing ain't getting worked on before 8.1.
Relevant logs
Traceback (most recent call last):
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\site-packages\sopel\cli\run.py", line 78, in run
p.run(settings.core.host, int(settings.core.port))
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\site-packages\sopel\irc\__init__.py", line 380, in run
self.backend.run_forever()
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\site-packages\sopel\irc\backends.py", line 562, in run_forever
asyncio.run(self._run_forever())
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\site-packages\sopel\irc\backends.py", line 480, in _run_forever
self._loop.add_signal_handler(quit_signal, self._signal_quit)
File "C:\Users\dgw\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 582, in add_signal_handler
raise NotImplementedError
NotImplementedError
Notes
If I comment out the add_signal_handler() calls shown above, Sopel runs just fine (modulo #1382 issues with stopping it; one must press Ctrl-C twice to actually stop the bot, else it will reconnect after 20 seconds).
Implementation-wise, the stdlib signal library could help with fixing this.
Line numbers in sopel/irc/backends.py might be slightly off in the traceback I attached because I was modifying my local copy to debug things and did not revert those edits before starting to write this issue.
Description
When run on Windows, Sopel appears to hang after
asyncio
emits the log line, "Using proactor: IocpProactor".Under the hood, what actually happens here is that the event loop starts, but trying to set up a signal handler (code excerpt below) raises
NotImplementedError
on Windows and execution stalls.https://github.com/sopel-irc/sopel/blob/ab32aca08f7bf67d1ba754fdfc22a10ee5a442d0/sopel/irc/backends.py#L478-L482
The error and traceback is logged to
configname.exceptions.log
.Reproduction steps
Expected behavior
Sopel's signal handling needs a rework to behave at least somewhat correctly cross-platform, even if the Windows code path can't fully support all features offered on Unix-like platforms.
There is probably a way to make everything work, with a bit of "AI" (read:
if
/else
checks). I just haven't looked into it because this whole thing ain't getting worked on before 8.1.Relevant logs
Notes
If I comment out the
add_signal_handler()
calls shown above, Sopel runs just fine (modulo #1382 issues with stopping it; one must press Ctrl-C twice to actually stop the bot, else it will reconnect after 20 seconds).Implementation-wise, the stdlib
signal
library could help with fixing this.Line numbers in
sopel/irc/backends.py
might be slightly off in the traceback I attached because I was modifying my local copy to debug things and did not revert those edits before starting to write this issue.Sopel version
3261d9c714fdc05ea373cc71842eb70e2f3cbb6b
Installation method
pip install
Python version
3.12.3
Operating system
Windows 11
IRCd
No response
Relevant plugins
No response