summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-31 15:25:24 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-31 15:25:24 (GMT)
commitf2e1768bc17d199f2ad81d7786e0150585c7cdb4 (patch)
treec8161bcf211c110e0a3a6e9e1a32cbcbe9e50c8c /Lib/asyncio
parent665758f804e81ad3217f1f556700b618686d920f (diff)
downloadcpython-f2e1768bc17d199f2ad81d7786e0150585c7cdb4.zip
cpython-f2e1768bc17d199f2ad81d7786e0150585c7cdb4.tar.gz
cpython-f2e1768bc17d199f2ad81d7786e0150585c7cdb4.tar.bz2
Issue #20455: asyncio: use the same code to round a timeout than the selectors
module Sort also imports
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/windows_events.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index d01de2f..0a2d981 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -1,11 +1,12 @@
"""Selector and proactor eventloops for Windows."""
+import _winapi
import errno
+import math
import socket
+import struct
import subprocess
import weakref
-import struct
-import _winapi
from . import events
from . import base_subprocess
@@ -325,7 +326,9 @@ class IocpProactor:
if timeout is None:
ms = _winapi.INFINITE
else:
- ms = int(timeout * 1000 + 0.5)
+ # RegisterWaitForSingleObject() has a resolution of 1 millisecond,
+ # round away from zero to wait *at least* timeout seconds.
+ ms = math.ceil(timeout * 1e3)
# We only create ov so we can use ov.address as a key for the cache.
ov = _overlapped.Overlapped(NULL)
@@ -396,7 +399,9 @@ class IocpProactor:
elif timeout < 0:
raise ValueError("negative timeout")
else:
- ms = int(timeout * 1000 + 0.5)
+ # GetQueuedCompletionStatus() has a resolution of 1 millisecond,
+ # round away from zero to wait *at least* timeout seconds.
+ ms = math.ceil(timeout * 1e3)
if ms >= INFINITE:
raise ValueError("timeout too big")
while True: