Created
September 25, 2014 06:10
-
-
Save goretkin/1973cb3735d03b04cc95 to your computer and use it in GitHub Desktop.
shows that python's inputhook gets called at about 10Hz
This file contains 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
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