Skip to content

Commit 61e2d5f

Browse files
SLdragonulyssessouza
authored andcommitted
Fix win32pipe.WaitNamedPipe throw exception in windows container.
Signed-off-by: Renlong Tu <[email protected]>
1 parent a67d180 commit 61e2d5f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docker/transport/npipesocket.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import functools
2+
import time
23
import io
34

45
import six
@@ -9,7 +10,7 @@
910
cSECURITY_SQOS_PRESENT = 0x100000
1011
cSECURITY_ANONYMOUS = 0
1112

12-
RETRY_WAIT_TIMEOUT = 10000
13+
MAXIMUM_RETRY_COUNT = 10
1314

1415

1516
def check_closed(f):
@@ -46,8 +47,7 @@ def close(self):
4647
self._closed = True
4748

4849
@check_closed
49-
def connect(self, address):
50-
win32pipe.WaitNamedPipe(address, self._timeout)
50+
def connect(self, address, retry_count=0):
5151
try:
5252
handle = win32file.CreateFile(
5353
address,
@@ -65,8 +65,10 @@ def connect(self, address):
6565
# Another program or thread has grabbed our pipe instance
6666
# before we got to it. Wait for availability and attempt to
6767
# connect again.
68-
win32pipe.WaitNamedPipe(address, RETRY_WAIT_TIMEOUT)
69-
return self.connect(address)
68+
retry_count = retry_count + 1
69+
if (retry_count < MAXIMUM_RETRY_COUNT):
70+
time.sleep(1)
71+
return self.connect(address, retry_count)
7072
raise e
7173

7274
self.flags = win32pipe.GetNamedPipeInfo(handle)[0]

0 commit comments

Comments
 (0)