Really fix deadlock causing race condition
This commit is contained in:
parent
97de6a0175
commit
aa7eea6242
@ -34,13 +34,12 @@ class PipeReaderThread(Thread):
|
|||||||
return open(self._pipe_path, 'rb')
|
return open(self._pipe_path, 'rb')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._unblock()
|
while self.is_alive():
|
||||||
|
self._unblock()
|
||||||
self.join()
|
self.join()
|
||||||
|
|
||||||
def _unblock(self):
|
def _unblock(self):
|
||||||
while True:
|
with suppress(OSError):
|
||||||
with suppress(OSError):
|
fd = osopen(self._pipe_path, O_WRONLY | O_NONBLOCK)
|
||||||
fd = osopen(self._pipe_path, O_WRONLY | O_NONBLOCK)
|
write(fd, self.stop_sequence)
|
||||||
write(fd, self.stop_sequence)
|
close(fd)
|
||||||
close(fd)
|
|
||||||
break
|
|
||||||
|
@ -39,13 +39,12 @@ class PipeWriterThread(Thread):
|
|||||||
return open(self._pipe_path, 'wb')
|
return open(self._pipe_path, 'wb')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._unblock()
|
while self.is_alive():
|
||||||
|
self._unblock()
|
||||||
self.join()
|
self.join()
|
||||||
|
|
||||||
def _unblock(self):
|
def _unblock(self):
|
||||||
while True:
|
with suppress(OSError):
|
||||||
with suppress(OSError):
|
fd = osopen(self._pipe_path, O_RDONLY | O_NONBLOCK)
|
||||||
fd = osopen(self._pipe_path, O_RDONLY | O_NONBLOCK)
|
self._write_queue.push_front(None)
|
||||||
self._write_queue.push_front(None)
|
close(fd)
|
||||||
close(fd)
|
|
||||||
break
|
|
||||||
|
Loading…
Reference in New Issue
Block a user