From 1d32ed3b5a809d7dbac3569b51abfdb9b88f17c8 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 2 Nov 2018 10:04:11 +0000 Subject: [PATCH] core: avoid shutdown() in IoLogger on WSL; closes #333. --- mitogen/core.py | 5 ++++- mitogen/parent.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index faa2d516..83880621 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -108,6 +108,7 @@ try: except NameError: BaseException = Exception +IS_WSL = 'Microsoft' in os.uname()[2] PY3 = sys.version_info > (3,) if PY3: b = str.encode @@ -1920,7 +1921,9 @@ class IoLogger(BasicStream): def on_shutdown(self, broker): """Shut down the write end of the logging socket.""" _v and LOG.debug('%r.on_shutdown()', self) - self._wsock.shutdown(socket.SHUT_WR) + if not IS_WSL: + # #333: WSL generates invalid readiness indication on shutdown() + self._wsock.shutdown(socket.SHUT_WR) self._wsock.close() self.transmit_side.close() diff --git a/mitogen/parent.py b/mitogen/parent.py index a11b362e..0fffdd67 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -68,7 +68,6 @@ from mitogen.core import LOG from mitogen.core import IOLOG -IS_WSL = 'Microsoft' in os.uname()[2] itervalues = getattr(dict, 'itervalues', dict.values) if mitogen.core.PY3: @@ -178,7 +177,7 @@ def disable_echo(fd): old = termios.tcgetattr(fd) new = cfmakeraw(old) flags = getattr(termios, 'TCSASOFT', 0) - if not IS_WSL: + if not mitogen.core.IS_WSL: # issue #319: Windows Subsystem for Linux as of July 2018 throws EINVAL # if TCSAFLUSH is specified. flags |= termios.TCSAFLUSH