Created
November 15, 2012 18:46
-
-
Save lukecampbell/4080397 to your computer and use it in GitHub Desktop.
IPython gevent wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import select | |
import gevent | |
def stdin_ready(): | |
infds, outfds, erfds = select.select([sys.stdin], [], [], 0) | |
if infds: | |
return True | |
else: | |
return False | |
def inputhook_gevent(): | |
try: | |
while not stdin_ready(): | |
gevent.sleep(0.001) | |
except KeyboardInterrupt: | |
pass | |
return 0 | |
# install the gevent inputhook | |
from IPython.lib.inputhook import inputhook_manager | |
inputhook_manager.set_inputhook(inputhook_gevent) | |
inputhook_manager._current_gui = 'gevent' | |
# First import the embeddable shell class | |
from IPython.frontend.terminal.embed import InteractiveShellEmbed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment