Message325354
If a signal handler callback is registered on an event loop, and the event loop has close() called on it, the close will fail.
Exception:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/nic/.pyenv/versions/3.7.0/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/nic/.pyenv/versions/3.7.0/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/nic/tmp/signal_event_loop_bug.py", line 9, in do_loop
loop.close()
File "/home/nic/.pyenv/versions/3.7.0/lib/python3.7/asyncio/unix_events.py", line 58, in close
self.remove_signal_handler(sig)
File "/home/nic/.pyenv/versions/3.7.0/lib/python3.7/asyncio/unix_events.py", line 147, in remove_signal_handler
signal.signal(sig, handler)
File "/home/nic/.pyenv/versions/3.7.0/lib/python3.7/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
Code:
import asyncio
import signal
import threading
def mysighandler():
pass
def do_loop(loop):
loop.close()
loop = asyncio.new_event_loop()
loop.add_signal_handler(signal.SIGINT, mysighandler)
t = threading.Thread(target=do_loop, args=(loop,))
t.start()
t.join() |
|
Date |
User |
Action |
Args |
2018-09-14 15:33:28 | jnwatson | set | recipients:
+ jnwatson, asvetlov, yselivanov |
2018-09-14 15:33:28 | jnwatson | set | messageid: <1536939208.48.0.956365154283.issue34680@psf.upfronthosting.co.za> |
2018-09-14 15:33:28 | jnwatson | link | issue34680 messages |
2018-09-14 15:33:28 | jnwatson | create | |
|