docker-py
docker-py copied to clipboard
Use poll() instead of select()
Fixes #2278 because poll does not have select's builtin limit of 1024 descriptors
This pr does not contain any updates to tests although it probably should. I'm also not 100% sure it is a proper fix, but it does solve the issue of #2278 when tested manually.
Please sign your commits following these rules: https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work The easiest way to do this is to amend the last commit:
$ git clone -b "master" [email protected]:bieron/docker-py.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f
Amending updates the existing PR. You DO NOT need to open a new one.
Unfortunately, select.poll
doesn't exist on Windows, so this'll definitely need more work -- maybe by continuing to use select.select
if we're running on Windows.
I'm also curious as to whether there's a non-manufactured case where more than 1024 sockets are open on a client machine at the same time? That seems like a lot.
You're correct about lack of select.poll. It's not only windows, but also using eventlet (e.g. in celery) magically patches your select module, removing poll from it.
As for is this a real life problem I would say yes - remember that the limit is for fds, not just sockets. We actually encountered this problem when a process that had opened over a thousand files attempted Container.exec_run
This PR is not passing due to an already solved problem.
Please rebase your PR with master
Hi, just wanted to check in with this as I encounter the same issue. What is the status on this?
/usr/local/lib/python3.9/site-packages/docker/models/containers.py:198: in exec_run
exec_output = self.client.api.exec_start(
/usr/local/lib/python3.9/site-packages/docker/utils/decorators.py:19: in wrapped
return f(self, resource_id, *args, **kwargs)
/usr/local/lib/python3.9/site-packages/docker/api/exec_api.py:167: in exec_start
return self._read_from_socket(res, stream, tty=tty, demux=demux)
/usr/local/lib/python3.9/site-packages/docker/api/client.py:424: in _read_from_socket
return consume_socket_output(gen, demux=demux)
/usr/local/lib/python3.9/site-packages/docker/utils/socket.py:135: in consume_socket_output
return bytes().join(frames)
/usr/local/lib/python3.9/site-packages/docker/api/client.py:418: in <genexpr>
gen = (data for (_, data) in gen)
/usr/local/lib/python3.9/site-packages/docker/utils/socket.py:92: in frames_iter_no_tty
(stream, n) = next_frame_header(socket)
/usr/local/lib/python3.9/site-packages/docker/utils/socket.py:64: in next_frame_header
data = read_exactly(socket, 8)
/usr/local/lib/python3.9/site-packages/docker/utils/socket.py:49: in read_exactly
next_data = read(socket, n - len(data))
/usr/local/lib/python3.9/site-packages/docker/utils/socket.py:29: in read
select.select([socket], [], [])
E ValueError: filedescriptor out of range in select()