Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPC timeout incoherence #6146

Merged
merged 1 commit into from
Jan 5, 2019
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
4 changes: 2 additions & 2 deletions mypy/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def close(self) -> None:
class IPCClient(IPCBase):
"""The client side of an IPC connection."""

def __init__(self, name: str, timeout: Optional[int]) -> None:
def __init__(self, name: str, timeout: Optional[float]) -> None:
super().__init__(name)
if sys.platform == 'win32':
timeout = timeout or 0xFFFFFFFF # NMPWAIT_WAIT_FOREVER
timeout = int(timeout * 1000) if timeout else 0xFFFFFFFF # NMPWAIT_WAIT_FOREVER
try:
_winapi.WaitNamedPipe(self.name, timeout)
except FileNotFoundError:
Expand Down
6 changes: 3 additions & 3 deletions mypy/test/testipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_transaction_large(self) -> None:
p = Process(target=server, args=(msg, queue), daemon=True)
p.start()
connection_name = queue.get()
with IPCClient(connection_name, timeout=1000) as client:
with IPCClient(connection_name, timeout=1) as client:
assert client.read() == msg.encode()
client.write(b'test')
queue.close()
Expand All @@ -41,11 +41,11 @@ def test_connect_twice(self) -> None:
p = Process(target=server, args=(msg, queue), daemon=True)
p.start()
connection_name = queue.get()
with IPCClient(connection_name, timeout=1000) as client:
with IPCClient(connection_name, timeout=1) as client:
assert client.read() == msg.encode()
client.write(b'') # don't let the server hang up yet, we want to connect again.

with IPCClient(connection_name, timeout=1000) as client:
with IPCClient(connection_name, timeout=1) as client:
assert client.read() == msg.encode()
client.write(b'test')
queue.close()
Expand Down