Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fakessh.Process.wake() can never return on Python < 2.7 #55

Closed
moreati opened this issue Oct 22, 2017 · 2 comments
Closed

fakessh.Process.wake() can never return on Python < 2.7 #55

moreati opened this issue Oct 22, 2017 · 2 comments

Comments

@moreati
Copy link
Member

moreati commented Oct 22, 2017

The function waits until self.wake_event.wait(0.1) returns True, wait_event is an instance of threading.Event https://github.com/dw/mitogen/blob/a8dcd53ccca0d6fffc4568bc216ddedeed610474/mitogen/fakessh.py#L162-L164

However in Python 2.6 and earlier Event.wait() always returns None

This method returns the internal flag on exit, so it will always return True except if a timeout is given and the operation times out.

Changed in version 2.7: Previously, the method always returned None.

@moreati
Copy link
Member Author

moreati commented Oct 22, 2017

I see two possible fixes for this

  1. Don't specify a timeout, and remove the while loop.
  2. Something like
            # NB: Before Python 2.7 threading.Event.wait() always returns None. 
            #     On Python 2.7+ it returns True, unless the timeout is reached.
            while not self.wake_event.wait(0.1) and not self.wake_event.isSet():
                pass

ETA: my multithreaded fu is weak though, so holding off on a PR

@dw dw closed this as completed in 325f532 Oct 23, 2017
@dw
Copy link
Member

dw commented Oct 23, 2017

Well spotted! Thanks again :)

PatrickCoakley23 pushed a commit to cyara/mitogen that referenced this issue Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants