diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-01-15 10:48:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-15 10:48:00 (GMT) |
commit | b1e45739d832e1e402a563c6727defda92e193b7 (patch) | |
tree | ae3340682e19f2a113d607dc2d2d81379edf0841 | |
parent | 06f8b57212b2e2cd2e63af36cecdfa3075b324a2 (diff) | |
download | cpython-b1e45739d832e1e402a563c6727defda92e193b7.zip cpython-b1e45739d832e1e402a563c6727defda92e193b7.tar.gz cpython-b1e45739d832e1e402a563c6727defda92e193b7.tar.bz2 |
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.
-rw-r--r-- | Lib/asyncio/windows_events.py | 18 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2019-01-14-17-34-36.bpo-34323.CRErrt.rst | 3 |
2 files changed, 18 insertions, 3 deletions
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py index bdb9a6e..7f264e6 100644 --- a/Lib/asyncio/windows_events.py +++ b/Lib/asyncio/windows_events.py @@ -7,6 +7,7 @@ import math import msvcrt import socket import struct +import time import weakref from . import events @@ -802,10 +803,21 @@ class IocpProactor: 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 = [] diff --git a/Misc/NEWS.d/next/Library/2019-01-14-17-34-36.bpo-34323.CRErrt.rst b/Misc/NEWS.d/next/Library/2019-01-14-17-34-36.bpo-34323.CRErrt.rst new file mode 100644 index 0000000..5926924 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-01-14-17-34-36.bpo-34323.CRErrt.rst @@ -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. |