Skip to content

unresponsive after gevent.monkey.patch_all() #112

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

Open
JohnLunzer opened this issue May 2, 2016 · 4 comments
Open

unresponsive after gevent.monkey.patch_all() #112

JohnLunzer opened this issue May 2, 2016 · 4 comments
Labels

Comments

@JohnLunzer
Copy link

as it says, after I run:

from gevent import monkey; monkey.patch_all()

ptpython becomes unresponsive with no error message. There may be a clue from running ptipython I get this error message before the terminal becomes unresponseive:

The history saving thread hit an unexpected error (LoopExit('This operation would block forever',)).History will not be written to the databa.

I'm using git clones of ptpython and prompt-toolkit from about an hour ago.

@jonathanslenders
Copy link
Member

Thanks for this. Not sure what's going on, but this needs some investigation.

@mguijarr
Copy link

I experienced the same issue, I could workaround it temporarily by doing:

from gevent import monkey; monkey.patch_all(thread=False)

(of course, threads are not replaced by greenlets in this case, but this was ok for me)

Unfortunately it brought another problem: in the posix event loop some threads are created,
and for some reason it was not properly cleaned up so each time a thread was created it was
opening a new file descriptor for a new gevent loop (one for each thread, since they are not
patched), and left it opened until the limit of opened files was reached.

I decided to go for my own gevent-friendly event loop, hopefully I will soon make a PR for the
project if people are interested ?

@JohnLunzer
Copy link
Author

Definitely interested in a fix. Thank you for looking into it more deeply than I did.

mguijarr added a commit to mguijarr/ptpython that referenced this issue Jul 13, 2016
…t#112)

The gevent-compliant event loop is activated by passing `gevent=True`
to the `embed` method of `repl` module.
The event loop code is heavily inspired from the prompt-toolkit POSIX
event loop, adapted to gevent. More details in file `contrib/gevent_eventloop.py`
@mguijarr
Copy link

mguijarr commented Jul 13, 2016

I finally made a PR, I hope it helps - I do not have much time to dedicate on this, but at least you should see how I solved the problem.

I realize a new event loop should probably go to the prompt-toolkit project ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants