Skip to content

Commit 566b301

Browse files
msullivanemmatyping
authored andcommitted
Fix IPC timeout incoherence (#6146)
Make IPCClient's timeout parameter be consistently seconds, rather than seconds on unix and milliseconds on windows. Fixes #5983
1 parent 0156714 commit 566b301

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

mypy/ipc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ def close(self) -> None:
9494
class IPCClient(IPCBase):
9595
"""The client side of an IPC connection."""
9696

97-
def __init__(self, name: str, timeout: Optional[int]) -> None:
97+
def __init__(self, name: str, timeout: Optional[float]) -> None:
9898
super().__init__(name)
9999
if sys.platform == 'win32':
100-
timeout = timeout or 0xFFFFFFFF # NMPWAIT_WAIT_FOREVER
100+
timeout = int(timeout * 1000) if timeout else 0xFFFFFFFF # NMPWAIT_WAIT_FOREVER
101101
try:
102102
_winapi.WaitNamedPipe(self.name, timeout)
103103
except FileNotFoundError:

mypy/test/testipc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_transaction_large(self) -> None:
2828
p = Process(target=server, args=(msg, queue), daemon=True)
2929
p.start()
3030
connection_name = queue.get()
31-
with IPCClient(connection_name, timeout=1000) as client:
31+
with IPCClient(connection_name, timeout=1) as client:
3232
assert client.read() == msg.encode()
3333
client.write(b'test')
3434
queue.close()
@@ -41,11 +41,11 @@ def test_connect_twice(self) -> None:
4141
p = Process(target=server, args=(msg, queue), daemon=True)
4242
p.start()
4343
connection_name = queue.get()
44-
with IPCClient(connection_name, timeout=1000) as client:
44+
with IPCClient(connection_name, timeout=1) as client:
4545
assert client.read() == msg.encode()
4646
client.write(b'') # don't let the server hang up yet, we want to connect again.
4747

48-
with IPCClient(connection_name, timeout=1000) as client:
48+
with IPCClient(connection_name, timeout=1) as client:
4949
assert client.read() == msg.encode()
5050
client.write(b'test')
5151
queue.close()

0 commit comments

Comments
 (0)