def inputhook_pyglet():
 try:
  t = clock()
  while (not stdin_ready()):
   pyglet.clock.tick()
   for window in pyglet.app.windows:
    window.switch_to()
    window.dispatch_events()
    window.dispatch_event('on_draw')
    flip(window)
   used_time = (clock() - t)
   if (used_time > 10.0):
    time.sleep(1.0)
   elif (used_time > 0.1):
    time.sleep(0.05)
   else:
    time.sleep(0.001)
 except KeyboardInterrupt:
  pass
 return 0

def inputhook_pyglet ( ) : try : t = clock ( ) while ( not stdin_ready ( ) ) : pyglet . clock . tick ( ) for window in pyglet . app . windows : window . switch_to ( ) window . dispatch_events ( ) window . dispatch_event ( 'on_draw' ) flip ( window ) used_time = ( clock ( ) - t ) if ( used_time > 10.0 ) : time . sleep ( 1.0 ) elif ( used_time > 0.1 ) : time . sleep ( 0.05 ) else : time . sleep ( 0.001 ) except KeyboardInterrupt : pass return 0
run the pyglet event loop by processing pending events only .