def iwait(objects, timeout=None):
 waiter = Waiter()
 switch = waiter.switch
 if (timeout is not None):
  timer = get_hub().loop.timer(timeout, priority=(-1))
  timer.start(waiter.switch, _NONE)
 try:
  count = len(objects)
  for obj in objects:
   obj.rawlink(switch)
  for _ in xrange(count):
   item = waiter.get()
   waiter.clear()
   if (item is _NONE):
    return
   (yield item)
 finally:
  if (timeout is not None):
   timer.stop()
  for obj in objects:
   unlink = getattr(obj, 'unlink', None)
   if unlink:
    try:
     unlink(switch)
    except:
     traceback.print_exc()

def iwait ( objects , timeout = None ) : waiter = Waiter ( ) switch = waiter . switch if ( timeout is not None ) : timer = get_hub ( ) . loop . timer ( timeout , priority = ( - 1 ) ) timer . start ( waiter . switch , _NONE ) try : count = len ( objects ) for obj in objects : obj . rawlink ( switch ) for _ in xrange ( count ) : item = waiter . get ( ) waiter . clear ( ) if ( item is _NONE ) : return ( yield item ) finally : if ( timeout is not None ) : timer . stop ( ) for obj in objects : unlink = getattr ( obj , 'unlink' , None ) if unlink : try : unlink ( switch ) except : traceback . print_exc ( )
iteratively yield *objects* as they are ready .