forked from M-Labs/artiq
1
0
Fork 0

protocols/pipe_ipc: work around race condition with loop.start_serving_pipe/close on Windows

This commit is contained in:
Sebastien Bourdeauducq 2016-02-19 17:39:30 +01:00
parent 28c4d8c2a7
commit 5f5427f51f
1 changed files with 10 additions and 1 deletions

View File

@ -141,7 +141,16 @@ else: # windows
asyncio.ensure_future(self._autoclose()) asyncio.ensure_future(self._autoclose())
def _child_connected(self, reader, writer): def _child_connected(self, reader, writer):
self.server[0].close() # HACK: We should shut down the pipe server here.
# However, self.server[0].close() is racy, and will cause an
# invalid handle error if loop.start_serving_pipe has not finished
# its work in the background.
# The bug manifests itself here frequently as the event loop is
# reopening the server as soon as a new client connects.
# There is still a race condition in the AsyncioParentComm
# creation/destruction, but it is unlikely to cause problems
# in most practical cases.
assert self.server is not None
self.server = None self.server = None
self.reader = reader self.reader = reader
self.writer = writer self.writer = writer