Skip to content

Commit

Permalink
mitogen.fakessh: Fix socket AttributeError on Python 2.x
Browse files Browse the repository at this point in the history
> 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).
-- mitogen-hq#683 (comment)

Co-authored-by: Ryan Ofsky <[email protected]
  • Loading branch information
moreati committed Apr 26, 2022
1 parent 313115c commit 4742e2a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mitogen/fakessh.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,13 @@ def run(dest, router, args, deadline=None, econtext=None):
fakessh.name = u'fakessh.%d' % (context_id,)

sock1, sock2 = socket.socketpair()
sock1.set_inheritable(True)
sock2.set_inheritable(True)
try:
# Python 3.x only
sock1.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.name = u'fakessh'
Expand Down

0 comments on commit 4742e2a

Please sign in to comment.