def read(self, n, timeout_sec): self._port.timeout = timeout_sec to_return = self._port.read(n) if not to_return: raise server.IoTimeoutError() return to_return
def _await_ready(self, rlist, wlist, timeout_sec=None, end_time=None): if timeout_sec is None and end_time is not None: timeout_sec = max(0, end_time - time.monotonic()) rlist, wlist, xlist = select.select(rlist, wlist, rlist + wlist, timeout_sec) if not rlist and not wlist and not xlist: raise server.IoTimeoutError() return True