Skip to content

Instantly share code, notes, and snippets.

@goretkin
Created September 25, 2014 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goretkin/1973cb3735d03b04cc95 to your computer and use it in GitHub Desktop.
Save goretkin/1973cb3735d03b04cc95 to your computer and use it in GitHub Desktop.
shows that python's inputhook gets called at about 10Hz
if __name__=="__main__":
def run_from_ipython():
try:
__IPYTHON__
return True
except NameError:
return False
if not run_from_ipython():
while domain.running:
print '.'
else:
print 'running from ipython'
from IPython.lib import inputhook
#ihm = inputhook.InputHookManager()
#old_hook = inputhook.clear_inputhook()
#print old_hook
i = 0
def step():
global i
print i
i += 1
if i>25:
inputhook.inputhook_manager.clear_inputhook()
return 0
inputhook.set_inputhook(step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment