def poll(self, timeout): """indicates whether the stream has data to read (within *timeout* seconds)""" timeout = Timeout(timeout) try: p = poll() # from lib.compat, it may be a select object on non-Unix platforms p.register(self.fileno(), "r") while True: try: rl = p.poll(timeout.timeleft()) except select_error: ex = sys.exc_info()[1] if ex.args[0] == errno.EINTR: continue else: raise else: break except ValueError: # if the underlying call is a select(), then the following errors may happen: # - "ValueError: filedescriptor cannot be a negative integer (-1)" # - "ValueError: filedescriptor out of range in select()" # let's translate them to select.error ex = sys.exc_info()[1] raise select_error(str(ex)) return bool(rl)
def poll(self, timeout): """indicates whether the stream has data to read (within *timeout* seconds)""" try: rl, _, _ = select([self], [], [], timeout) except ValueError: # i got this once: "ValueError: file descriptor cannot be a negative integer (-1)" # let's translate it to select.error ex = sys.exc_info()[1] raise select_error(str(ex)) return bool(rl)
def poll(self, timeout): """indicates whether the stream has data to read (within *timeout* seconds)""" try: rl, _, _ = select([self], [], [], timeout) except ValueError: # i get this some times: "ValueError: file descriptor cannot be a negative integer (-1)" # let's translate it to select.error ex = sys.exc_info()[1] raise select_error(str(ex)) return bool(rl)
def poll(self, timeout): """indicates whether the stream has data to read (within *timeout* seconds)""" try: while True: try: rl, _, _ = select([self], [], [], timeout) except select_error as ex: if ex[0] == errno.EINTR: continue else: raise else: break except ValueError as ex: # i get this some times: "ValueError: file descriptor cannot be a negative integer (-1)" # let's translate it to select.error raise select_error(str(ex)) return bool(rl)