Permalink
Browse files

shell.py: make ipython yield for gevent

  • Loading branch information...
1 parent 39e6673 commit 534997ec5dd7864cfe95c6a93786032bad681488 @trey0 trey0 committed Oct 15, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 geocamPycroraptor2/shell.py
View
11 geocamPycroraptor2/shell.py
@@ -10,6 +10,7 @@
import zerorpc
from IPython.config.loader import Config
from IPython.frontend.terminal.embed import InteractiveShellEmbed
+from IPython.lib.inputhook import inputhook_manager, stdin_ready
from geocamPycroraptor2.util import loadConfig
@@ -24,6 +25,16 @@
ipshell = InteractiveShellEmbed(config=Config(),
banner1=INTRO)
+def inputhook_gevent():
+ try:
+ while not stdin_ready():
+ gevent.sleep(0.05)
+ except KeyboardInterrupt:
+ pass
+ return 0
+
+# tell ipython to use gevent as the mainloop
+inputhook_manager.set_inputhook(inputhook_gevent)
class Shell(object):
def __init__(self, configPath):

0 comments on commit 534997e

Please sign in to comment.