Skip to content

Commit

Permalink
protocols/pipe_ipc: work around race condition with loop.start_servin…
Browse files Browse the repository at this point in the history
…g_pipe/close on Windows
sbourdeauducq committed Feb 19, 2016
1 parent 28c4d8c commit 5f5427f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion artiq/protocols/pipe_ipc.py
Original file line number Diff line number Diff line change
@@ -141,7 +141,16 @@ def factory():
asyncio.ensure_future(self._autoclose())

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.reader = reader
self.writer = writer

0 comments on commit 5f5427f

Please sign in to comment.