Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Lib/test/test_asyncio/test_windows_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@ class ProactorLoopCtrlC(test_utils.TestCase):
def test_ctrl_c(self):

def SIGINT_after_delay():
time.sleep(1)
time.sleep(0.1)
signal.raise_signal(signal.SIGINT)

asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
l = asyncio.get_event_loop()
thread = threading.Thread(target=SIGINT_after_delay)
loop = asyncio.get_event_loop()
try:
t = threading.Thread(target=SIGINT_after_delay)
t.start()
l.run_forever()
# only start the loop once the event loop is running
loop.call_soon(thread.start)
loop.run_forever()
self.fail("should not fall through 'run_forever'")
except KeyboardInterrupt:
pass
finally:
l.close()
self.close_loop(loop)
thread.join()


class ProactorTests(test_utils.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix test_asyncio ProactorLoopCtrlC: join the thread to prevent leaking a
running thread and leaking a reference.