File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,18 @@ def handler_hup():
262
262
263
263
self .loop .run_until_complete (runner ())
264
264
265
+ def test_signals_invalid_signal (self ):
266
+ with self .assertRaisesRegex (RuntimeError ,
267
+ 'sig {} cannot be caught' .format (
268
+ signal .SIGKILL )):
269
+
270
+ self .loop .add_signal_handler (signal .SIGKILL , lambda * a : None )
271
+
272
+ def test_signals_coro_callback (self ):
273
+ async def coro (): pass
274
+ with self .assertRaisesRegex (TypeError , 'coroutines cannot be used' ):
275
+ self .loop .add_signal_handler (signal .SIGHUP , coro )
276
+
265
277
266
278
class Test_UV_Signals (_TestSignal , tb .UVTestCase ):
267
279
NEW_LOOP = 'uvloop.new_event_loop()'
Original file line number Diff line number Diff line change @@ -59,3 +59,4 @@ cdef extern from "errno.h" nogil:
59
59
int ENOTSOCK
60
60
int EBADF
61
61
int ENOSYS
62
+ int EINVAL
Original file line number Diff line number Diff line change @@ -1657,7 +1657,14 @@ cdef class Loop:
1657
1657
# any signals installed by user
1658
1658
return
1659
1659
1660
- uvs.start()
1660
+ try :
1661
+ uvs.start()
1662
+ except OSError as exc:
1663
+ del self ._signal_handlers[sig]
1664
+ if exc.errno == errno.EINVAL:
1665
+ raise RuntimeError (' sig {} cannot be caught' .format(sig))
1666
+ else :
1667
+ raise
1661
1668
1662
1669
def remove_signal_handler (self , sig ):
1663
1670
cdef:
You can’t perform that action at this time.
0 commit comments