From 0c0d34241b64799b30bebf4b28c8d4547a08bbf0 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 29 Jan 2019 05:02:34 +0000 Subject: [PATCH] core: Latch._wake improvements os.write() can fail with EINTR due to signals, so wrap it in io_op(). Closes #483. Masking EBADF looks like it is/was almost certainly papering over a bug, remove it and suffer the bug reports. Closes #495. --- mitogen/core.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index 9a5e85db..4bc754ba 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -2220,12 +2220,8 @@ class Latch(object): self._lock.release() def _wake(self, wsock, cookie): - try: - os.write(wsock.fileno(), cookie) - except OSError: - e = sys.exc_info()[1] - if e.args[0] != errno.EBADF: - raise + written, disconnected = io_op(os.write, wsock.fileno(), cookie) + assert written == len(cookie) and not disconnected def __repr__(self): return 'Latch(%#x, size=%d, t=%r)' % (