I am using python's gevent library and do not want raw_input
(or more specifically the event loop in cmd.Cmd) to block when awaiting user input. So as a result I use gevent.monkey.patch_sys()
to ensure that my other greenlets may run when waiting for user input. Works great except that it seems to interact with readline
.
For example, I no longer have history and auto-complete in ipython's ipdb debugger since the arrow keys no longer work. This can be seen with this simple snippet:
from gevent import monkey
monkey.patch_sys()
import ipdb; ipdb.set_trace()
# now hit arrow keys at the prompt
I get the following:
ipdb> ^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A
*** SyntaxError: invalid syntax (<stdin>, line 1)
I have traced it to what I think could be an issue with python's readline as I know that ipython depends on it.
Also this appears to be a similar situation:
https://github.com/gevent/gevent/issues/6
but in my case I want to specifically use auto completion and history in the debugger.
I am running on OSX within iterm. Is this something specific to a console setting? Or is something in the patch fundamentally breaking readline
?
Any ideas on how to resolve?