Skip to content

Commit

Permalink
Merge pull request #2421 from SLdragon/master
Browse files Browse the repository at this point in the history
Fix win32pipe.WaitNamedPipe throw exception in windows container
  • Loading branch information
rumpl authored Nov 6, 2019
2 parents 1d8aa30 + 015f44d commit a0b9c3d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docker/transport/npipesocket.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import time
import io

import six
Expand All @@ -9,7 +10,7 @@
cSECURITY_SQOS_PRESENT = 0x100000
cSECURITY_ANONYMOUS = 0

RETRY_WAIT_TIMEOUT = 10000
MAXIMUM_RETRY_COUNT = 10


def check_closed(f):
Expand Down Expand Up @@ -46,8 +47,7 @@ def close(self):
self._closed = True

@check_closed
def connect(self, address):
win32pipe.WaitNamedPipe(address, self._timeout)
def connect(self, address, retry_count=0):
try:
handle = win32file.CreateFile(
address,
Expand All @@ -65,8 +65,10 @@ def connect(self, address):
# Another program or thread has grabbed our pipe instance
# before we got to it. Wait for availability and attempt to
# connect again.
win32pipe.WaitNamedPipe(address, RETRY_WAIT_TIMEOUT)
return self.connect(address)
retry_count = retry_count + 1
if (retry_count < MAXIMUM_RETRY_COUNT):
time.sleep(1)
return self.connect(address, retry_count)
raise e

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

0 comments on commit a0b9c3d

Please sign in to comment.