Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dmw'
Browse files Browse the repository at this point in the history
* origin/dmw:
  issue #550: parent: add explanatory comment.
  issue #550: fix up TTY ioctls on WSL 2016 Anniversary Update
  docs: update Changelog.
  service: make service list optional.
  • Loading branch information
dw committed Feb 23, 2019
2 parents ebc5328 + bd4d55d commit a7df9cd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/changelog.rst
Expand Up @@ -176,7 +176,8 @@ Thanks!

Mitogen would not be possible without the support of users. A huge thanks for
bug reports, testing, features and fixes in this release contributed by
`Fabian Arrotin <https://github.com/arrfab>`_, and
`Fabian Arrotin <https://github.com/arrfab>`_,
`Percy Grunwald <https://github.com/percygrunwald>`_,
`Petr Enkov <https://github.com/enkov>`_, and
`@elbunda <https://github.com/elbunda>`_.

Expand Down
9 changes: 8 additions & 1 deletion mitogen/core.py
Expand Up @@ -140,7 +140,6 @@
except NameError:
BaseException = Exception

IS_WSL = 'Microsoft' in os.uname()[2]
PY24 = sys.version_info < (2, 5)
PY3 = sys.version_info > (3,)
if PY3:
Expand All @@ -164,6 +163,14 @@
except NameError:
next = lambda it: it.next()

# #550: prehistoric WSL did not advertise itself in uname output.
try:
fp = open('/proc/sys/kernel/osrelease')
IS_WSL = 'Microsoft' in fp.read()
fp.close()
except IOError:
IS_WSL = False


#: Default size for calls to :meth:`Side.read` or :meth:`Side.write`, and the
#: size of buffers configured by :func:`mitogen.parent.create_socketpair`. This
Expand Down
5 changes: 3 additions & 2 deletions mitogen/parent.py
Expand Up @@ -371,11 +371,12 @@ def create_child(args, merge_stdio=False, stderr_pipe=False, preexec_fn=None):

def _acquire_controlling_tty():
os.setsid()
if sys.platform == 'linux2':
if sys.platform in ('linux', 'linux2'):
# On Linux, the controlling tty becomes the first tty opened by a
# process lacking any prior tty.
os.close(os.open(os.ttyname(2), os.O_RDWR))
if hasattr(termios, 'TIOCSCTTY'):
if hasattr(termios, 'TIOCSCTTY') and not mitogen.core.IS_WSL:
# #550: prehistoric WSL does not like TIOCSCTTY.
# On BSD an explicit ioctl is required. For some inexplicable reason,
# Python 2.6 on Travis also requires it.
fcntl.ioctl(2, termios.TIOCSCTTY)
Expand Down
2 changes: 1 addition & 1 deletion mitogen/service.py
Expand Up @@ -451,7 +451,7 @@ class Pool(object):
"""
activator_class = Activator

def __init__(self, router, services, size=1, overwrite=False):
def __init__(self, router, services=(), size=1, overwrite=False):
self.router = router
self._activator = self.activator_class()
self._ipc_latch = mitogen.core.Latch()
Expand Down

0 comments on commit a7df9cd

Please sign in to comment.