From 0b69fbc6420115ce11e7f18249280a2c6d9a87ce Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 6 Nov 2013 20:25:50 -0800 Subject: asyncio: Add close() back to Unix selector event loop, to remove all signal handlers. Should fix buildbot issues. --- Lib/test/test_asyncio/test_unix_events.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Lib/test/test_asyncio/test_unix_events.py') diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index a4d835e3f4c..42eba8d6932 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -183,6 +183,22 @@ class SelectorEventLoopTests(unittest.TestCase): self.assertRaises( RuntimeError, self.loop.remove_signal_handler, signal.SIGHUP) + @unittest.mock.patch('asyncio.unix_events.signal') + def test_close(self, m_signal): + m_signal.NSIG = signal.NSIG + + self.loop.add_signal_handler(signal.SIGHUP, lambda: True) + self.loop.add_signal_handler(signal.SIGCHLD, lambda: True) + + self.assertEqual(len(self.loop._signal_handlers), 2) + + m_signal.set_wakeup_fd.reset_mock() + + self.loop.close() + + self.assertEqual(len(self.loop._signal_handlers), 0) + m_signal.set_wakeup_fd.assert_called_once_with(-1) + class UnixReadPipeTransportTests(unittest.TestCase): -- cgit v1.2.3