Commit b1e45739 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-34323: Enhance IocpProactor.close() log (GH-11555)

IocpProactor.close() now uses time to decide when to log: wait 1
second before the first log, then log every second. Log also the
number of seconds since close() was called.
parent 06f8b572
...@@ -7,6 +7,7 @@ import math ...@@ -7,6 +7,7 @@ import math
import msvcrt import msvcrt
import socket import socket
import struct import struct
import time
import weakref import weakref
from . import events from . import events
...@@ -802,10 +803,21 @@ class IocpProactor: ...@@ -802,10 +803,21 @@ class IocpProactor:
context['source_traceback'] = fut._source_traceback context['source_traceback'] = fut._source_traceback
self._loop.call_exception_handler(context) 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: while self._cache:
if not self._poll(1): if next_msg <= time.monotonic():
logger.debug('taking long time to close proactor') 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 = [] self._results = []
......
: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.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment