Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created November 15, 2012 18:46
Show Gist options
  • Save lukecampbell/4080397 to your computer and use it in GitHub Desktop.
Save lukecampbell/4080397 to your computer and use it in GitHub Desktop.
IPython gevent wrapper
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