def _wait_for_io_events(socks, events, timeout=None):
 if (not HAS_SELECT):
  raise ValueError('Platform does not have a selector')
 if (not isinstance(socks, list)):
  if hasattr(socks, 'fileno'):
   socks = [socks]
  else:
   socks = list(socks)
 with DefaultSelector() as selector:
  for sock in socks:
   selector.register(sock, events)
  return [key[0].fileobj for key in selector.select(timeout) if (key[1] & events)]

def _wait_for_io_events ( socks , events , timeout = None ) : if ( not HAS_SELECT ) : raise ValueError ( 'Platform does not have a selector' ) if ( not isinstance ( socks , list ) ) : if hasattr ( socks , 'fileno' ) : socks = [ socks ] else : socks = list ( socks ) with DefaultSelector ( ) as selector : for sock in socks : selector . register ( sock , events ) return [ key [ 0 ] . fileobj for key in selector . select ( timeout ) if ( key [ 1 ] & events ) ]
waits for io events to be available from a list of sockets or optionally a single socket if passed in .