You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
) it can trigger the PipeHandle.__del__ to be called in a different thread to the user code. Thus, there is a race between __del__ and PipeServer.close
classPipeServer(object):
"""Class representing a pipe server. This is much like a bound, listening socket. """def__init__(self, address):
self._address=addressself._free_instances=weakref.WeakSet()
# initialize the pipe attribute before calling _server_pipe_handle()# because this function can raise an exception and the destructor calls# the close() methodself._pipe=Noneself._accept_pipe_future=Noneself._pipe=self._server_pipe_handle(True)
def_get_unconnected_pipe(self):
# Create new instance and return previous one. This ensures# that (until the server is closed) there is always at least# one pipe handle for address. Therefore if a client attempt# to connect it will not fail with FileNotFoundError.tmp, self._pipe=self._pipe, self._server_pipe_handle(False)
returntmpdef_server_pipe_handle(self, first):
# Return a wrapper for a new pipe handle.ifself.closed():
returnNoneflags=_winapi.PIPE_ACCESS_DUPLEX|_winapi.FILE_FLAG_OVERLAPPEDiffirst:
flags |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCEh=_winapi.CreateNamedPipe(
self._address, flags,
_winapi.PIPE_TYPE_MESSAGE|_winapi.PIPE_READMODE_MESSAGE|_winapi.PIPE_WAIT,
_winapi.PIPE_UNLIMITED_INSTANCES,
windows_utils.BUFSIZE, windows_utils.BUFSIZE,
_winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL)
pipe=windows_utils.PipeHandle(h)
self._free_instances.add(pipe)
returnpipedefclosed(self):
return (self._addressisNone)
defclose(self):
ifself._accept_pipe_futureisnotNone:
self._accept_pipe_future.cancel()
self._accept_pipe_future=None# Close all instances which have not been connected to by a client.ifself._addressisnotNone:
forpipeinself._free_instances:
pipe.close()
self._pipe=Noneself._address=Noneself._free_instances.clear()
__del__=close
I'm tracking down a race in the
asyncio.windows_events.PipeServer
sclose
method. AFAICT the issue is this:weakref
s to eachPipeHandle
it opensPipeHandles
PipeHandles
quamash/quamash/__init__.py
Line 210 in e513b30
PipeHandle.__del__
to be called in a different thread to the user code. Thus, there is a race between__del__
andPipeServer.close
Possibly related to #55
Any suggestions for a fix for this? Thanks!
Asyncio
PipeServer
code below for reference...https://github.com/python/cpython/blob/bfba8c373e362d48d4ee0e0cf55b8d9c169344ae/Lib/asyncio/windows_events.py#L241-L297
The text was updated successfully, but these errors were encountered: