def select(rlist, wlist, xlist, timeout=None):
 allevents = []
 timeout = Timeout.start_new(timeout)
 result = SelectResult()
 try:
  try:
   for readfd in rlist:
    allevents.append(core.read_event(get_fileno(readfd), result.update, arg=readfd))
   for writefd in wlist:
    allevents.append(core.write_event(get_fileno(writefd), result.update, arg=writefd))
  except IOError as ex:
   raise error(*ex.args)
  result.event.wait(timeout=timeout)
  return (result.read, result.write, [])
 finally:
  for evt in allevents:
   evt.cancel()
  timeout.cancel()

def select ( rlist , wlist , xlist , timeout = None ) : allevents = [ ] timeout = Timeout . start_new ( timeout ) result = SelectResult ( ) try : try : for readfd in rlist : allevents . append ( core . read_event ( get_fileno ( readfd ) , result . update , arg = readfd ) ) for writefd in wlist : allevents . append ( core . write_event ( get_fileno ( writefd ) , result . update , arg = writefd ) ) except IOError as ex : raise error ( * ex . args ) result . event . wait ( timeout = timeout ) return ( result . read , result . write , [ ] ) finally : for evt in allevents : evt . cancel ( ) timeout . cancel ( )
returns the ith order statistic in array a in linear time .