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
18 changes: 15 additions & 3 deletions Lib/asyncio/windows_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import msvcrt
import socket
import struct
import time
import weakref

from . import events
Expand Down Expand Up @@ -802,10 +803,21 @@ def close(self):
context['source_traceback'] = fut._source_traceback
self._loop.call_exception_handler(context)

# wait until all cancelled overlapped future complete
# Wait until all cancelled overlapped complete: don't exit with running
# overlapped to prevent a crash. Display progress every second if the
# loop is still running.
msg_update = 1.0
start_time = time.monotonic()
next_msg = start_time + msg_update
while self._cache:
if not self._poll(1):
logger.debug('taking long time to close proactor')
if next_msg <= time.monotonic():
logger.debug('IocpProactor.close(): '
'loop is running after closing for %.1f seconds',
time.monotonic() - start_time)
next_msg = time.monotonic() + msg_update

# handle a few events, or timeout
self._poll(msg_update)

self._results = []

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:mod:`asyncio`: Enhance ``IocpProactor.close()`` log: wait 1 second before
the first log, then log every second. Log also the number of seconds since
``close()`` was called.