def eventloop(conn, limit=None, timeout=None, ignore_timeouts=False):
 for i in ((limit and range(limit)) or count()):
  try:
   (yield conn.drain_events(timeout=timeout))
  except socket.timeout:
   if (timeout and (not ignore_timeouts)):
    raise

def eventloop ( conn , limit = None , timeout = None , ignore_timeouts = False ) : for i in ( ( limit and range ( limit ) ) or count ( ) ) : try : ( yield conn . drain_events ( timeout = timeout ) ) except socket . timeout : if ( timeout and ( not ignore_timeouts ) ) : raise
best practice generator wrapper around connection .