mitogen.fakessh: Fix socket AttributeError on Python 2.x

> the method only exists in python3. It should be pretty easy to fix because
the call isn't necessary in python2 (descriptors are inherited by default
there).
-- https://github.com/mitogen-hq/mitogen/pull/683#issuecomment-774690069

Co-authored-by: Ryan Ofsky <ryan@ofsky.org
pull/924/head
Alex Willmer 3 years ago
parent 313115cb93
commit 4742e2addd

@ -490,8 +490,13 @@ def run(dest, router, args, deadline=None, econtext=None):
fakessh.name = u'fakessh.%d' % (context_id,) fakessh.name = u'fakessh.%d' % (context_id,)
sock1, sock2 = socket.socketpair() sock1, sock2 = socket.socketpair()
try:
# Python 3.x only
sock1.set_inheritable(True) sock1.set_inheritable(True)
sock2.set_inheritable(True) sock2.set_inheritable(True)
except AttributeError:
# Python 2.x socket objects are always inheritable
pass
stream = mitogen.core.MitogenProtocol.build_stream(router, context_id, mitogen.context_id) stream = mitogen.core.MitogenProtocol.build_stream(router, context_id, mitogen.context_id)
stream.name = u'fakessh' stream.name = u'fakessh'

Loading…
Cancel
Save