Kaydet (Commit) 422bc2be authored tarafından Joffrey F's avatar Joffrey F

Fix NpipeSocket.settimeout to match expected behavior

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 4119fa93
...@@ -170,13 +170,16 @@ class NpipeSocket(object): ...@@ -170,13 +170,16 @@ class NpipeSocket(object):
def settimeout(self, value): def settimeout(self, value):
if value is None: if value is None:
self._timeout = win32pipe.NMPWAIT_NOWAIT # Blocking mode
self._timeout = win32pipe.NMPWAIT_WAIT_FOREVER
elif not isinstance(value, (float, int)) or value < 0: elif not isinstance(value, (float, int)) or value < 0:
raise ValueError('Timeout value out of range') raise ValueError('Timeout value out of range')
elif value == 0: elif value == 0:
self._timeout = win32pipe.NMPWAIT_USE_DEFAULT_WAIT # Non-blocking mode
self._timeout = win32pipe.NMPWAIT_NO_WAIT
else: else:
self._timeout = value # Timeout mode - Value converted to milliseconds
self._timeout = value * 1000
def gettimeout(self): def gettimeout(self):
return self._timeout return self._timeout
......
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