4from functools
import partial
7 from time
import monotonic
9 from time
import time
as monotonic
11__all__ = [
"NoWayToWaitForSocketError",
"wait_for_read",
"wait_for_write"]
49 deadline = float(
"inf")
51 deadline = monotonic() + timeout
62 timeout = deadline - monotonic()
65 if timeout == float(
"inf"):
71 if not read
and not write:
72 raise RuntimeError(
"must specify at least one of read=True, write=True")
86 return bool(rready
or wready
or xready)
90 if not read
and not write:
91 raise RuntimeError(
"must specify at least one of read=True, write=True")
120 except (AttributeError, OSError):
131 global wait_for_socket
133 wait_for_socket = poll_wait_for_socket
134 elif hasattr(select,
"select"):
135 wait_for_socket = select_wait_for_socket
137 wait_for_socket = null_wait_for_socket
141def wait_for_read(sock, timeout=None):
142 """Waits for reading to be available on a given socket.
143 Returns True if the socket is readable, or False if the timeout expired.
148def wait_for_write(sock, timeout=None):
149 """Waits for writing to be available on a given socket.
150 Returns True if the socket is readable, or False if the timeout expired.
_retry_on_intr(fn, timeout)
poll_wait_for_socket(sock, read=False, write=False, timeout=None)
wait_for_socket(*args, **kwargs)
null_wait_for_socket(*args, **kwargs)
select_wait_for_socket(sock, read=False, write=False, timeout=None)