diff options
| author | Yuval Adam <_@yuv.al> | 2019-10-09 17:34:14 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2019-10-09 18:02:35 +0300 |
| commit | a4c49f349536943517e200485cf968398e26276b (patch) | |
| tree | 9a7b565f736ccabde00a8cb8309cc6af6b90558c /cron/urllib3/util/wait.py | |
| parent | d762328ea6f75f50b6edae6e5c141977d22c39ee (diff) | |
Initial FTP implementation
Diffstat (limited to 'cron/urllib3/util/wait.py')
| -rw-r--r-- | cron/urllib3/util/wait.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/cron/urllib3/util/wait.py b/cron/urllib3/util/wait.py deleted file mode 100644 index cb396e5..0000000 --- a/cron/urllib3/util/wait.py +++ /dev/null @@ -1,40 +0,0 @@ -from .selectors import ( - HAS_SELECT, - DefaultSelector, - EVENT_READ, - EVENT_WRITE -) - - -def _wait_for_io_events(socks, events, timeout=None): - """ Waits for IO events to be available from a list of sockets - or optionally a single socket if passed in. Returns a list of - sockets that can be interacted with immediately. """ - if not HAS_SELECT: - raise ValueError('Platform does not have a selector') - if not isinstance(socks, list): - # Probably just a single socket. - if hasattr(socks, "fileno"): - socks = [socks] - # Otherwise it might be a non-list iterable. - 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_read(socks, timeout=None): - """ Waits for reading to be available from a list of sockets - or optionally a single socket if passed in. Returns a list of - sockets that can be read from immediately. """ - return _wait_for_io_events(socks, EVENT_READ, timeout) - - -def wait_for_write(socks, timeout=None): - """ Waits for writing to be available from a list of sockets - or optionally a single socket if passed in. Returns a list of - sockets that can be written to immediately. """ - return _wait_for_io_events(socks, EVENT_WRITE, timeout) |
