Cadair / parfive

An asyncio based parallel file downloader for Python 3.8+
https://parfive.readthedocs.io/
MIT License
50 stars 24 forks source link

Signal errors can be raised inside notebooks and other jupyter kernels #131

Open Cadair opened 1 year ago

Cadair commented 1 year ago

This is a little tricky to reliably reproduce but it seems that if you run enough downloads inside a jupyter kernel (where parfive's asyncio loop is running in a thread) the following message appears:

Exception ignored in: <function BaseEventLoop.__del__ at 0x7fe4320fc820>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/base_events.py", line 687, in __del__
    self.close()
  File "/usr/lib/python3.10/asyncio/unix_events.py", line 71, in close
    self.remove_signal_handler(sig)
  File "/usr/lib/python3.10/asyncio/unix_events.py", line 160, in remove_signal_handler
    signal.signal(sig, handler)
  File "/usr/lib/python3.10/signal.py", line 56, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter
Cadair commented 1 year ago

It seems to happen about 50% of the time:

Kooha-2023-05-12-17-02-55.webm