File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,9 @@ def close(self):
5656 self .remove_signal_handler (sig )
5757 else :
5858 if self ._signal_handlers :
59- warinigs .warn (f"Closing the loop { self !r} "
59+ warnings .warn (f"Closing the loop { self !r} "
6060 f"on interpreter shutdown "
61- f"stage, signal unsubsription is disabled " ,
61+ f"stage, skipping signal handlers removal " ,
6262 ResourceWarning ,
6363 source = self )
6464 self ._signal_handlers .clear ()
Original file line number Diff line number Diff line change @@ -229,6 +229,23 @@ def test_close(self, m_signal):
229229 self .assertEqual (len (self .loop ._signal_handlers ), 0 )
230230 m_signal .set_wakeup_fd .assert_called_once_with (- 1 )
231231
232+ @mock .patch ('asyncio.unix_events.sys' )
233+ @mock .patch ('asyncio.unix_events.signal' )
234+ def test_close_on_finalizing (self , m_signal , m_sys ):
235+ m_signal .NSIG = signal .NSIG
236+ self .loop .add_signal_handler (signal .SIGHUP , lambda : True )
237+
238+ self .assertEqual (len (self .loop ._signal_handlers ), 1 )
239+ m_sys .is_finalizing .return_value = True
240+ m_signal .signal .reset_mock ()
241+
242+ with self .assertWarnsRegex (ResourceWarning ,
243+ "skipping signal handlers removal" ):
244+ self .loop .close ()
245+
246+ self .assertEqual (len (self .loop ._signal_handlers ), 0 )
247+ self .assertFalse (m_signal .signal .called )
248+
232249
233250@unittest .skipUnless (hasattr (socket , 'AF_UNIX' ),
234251 'UNIX Sockets are not supported' )
You can’t perform that action at this time.
0 commit comments