Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use docker with eventlet since #2865 #3131

Closed
tito opened this issue May 16, 2023 · 0 comments · Fixed by #3132
Closed

Cannot use docker with eventlet since #2865 #3131

tito opened this issue May 16, 2023 · 0 comments · Fixed by #3132

Comments

@tito
Copy link
Contributor

tito commented May 16, 2023

Before #2865, it was possible to use docker-py with a eventlet-based project.
However, after the inclusion of a tests for using poll(), i now have errors, see below.

This is expected: eventlet removes poll function on the select module on purpose. See eventlet/eventlet#608 (comment)

So instead of checking if the platform is win32, we should check if the select module have a poll method. Which also make it more cross-platform compatible as per select.poll documentation (https://docs.python.org/3/library/select.html#select.poll - Not supported by all operating systems, but not mentionning win32 exactly.)

.venv/lib/python3.11/site-packages/docker/utils/socket.py:156: in consume_socket_output                                       [64/1813]
    return bytes().join(frames)                                                                                                        
.venv/lib/python3.11/site-packages/docker/api/client.py:422: in <genexpr>                                                              
    gen = (data for (_, data) in gen)                                                                                                  
.venv/lib/python3.11/site-packages/docker/utils/socket.py:113: in frames_iter_no_tty                                                   
    (stream, n) = next_frame_header(socket)                                                                                            
.venv/lib/python3.11/site-packages/docker/utils/socket.py:85: in next_frame_header                                                     
    data = read_exactly(socket, 8)                                                                                                     
.venv/lib/python3.11/site-packages/docker/utils/socket.py:70: in read_exactly                                                          
    next_data = read(socket, n - len(data))                                                                                            
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _      
                                                                                                                                       
socket = <socket.SocketIO object at 0x7f0f24f04c10>, n = 8                                                                             
                                                                                                                                       
    def read(socket, n=4096):                                                                                                          
        """                                                                                                                            
        Reads at most n bytes from socket                                                                                              
        """                                                                                                                            
                                                                                                                                       
        recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)                                                           
                                                                                                                                       
        if not isinstance(socket, NpipeSocket):                                                                                        
            if sys.platform == 'win32':                                                                                                
                # Limited to 1024                                  
                select.select([socket], [], [])                    
            else:                
>               poll = select.poll()                               
E               AttributeError: module 'select' has no attribute 'poll'                                                                

.venv/lib/python3.11/site-packages/docker/utils/socket.py:39: AttributeError   
tito added a commit to tito/docker-py that referenced this issue May 16, 2023
…form check

The implementation done in docker#2865 is breaking usage of docker-py library within eventlet.
As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (eventlet/eventlet#608 (comment)), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`.

Fixes docker#3131

Signed-off-by: Mathieu Virbel <mat@meltingrocks.com>
milas pushed a commit that referenced this issue Jun 1, 2023
Check if poll attribute exists on select module instead of win32 platform check

The implementation done in #2865 is breaking usage of docker-py library within eventlet.
As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (eventlet/eventlet#608 (comment)), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`.

Fixes #3131

Signed-off-by: Mathieu Virbel <mat@meltingrocks.com>
felixfontein added a commit to felixfontein/community.docker that referenced this issue Oct 7, 2023
Check if poll attribute exists on select module instead of win32 platform check

The implementation done in #2865 is breaking usage of docker-py library within eventlet.
As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (eventlet/eventlet#608 (comment)), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`.

Fixes docker/docker-py#3131

Cherry-picked from docker/docker-py@78439eb

Co-authored-by: Mathieu Virbel <mat@meltingrocks.com>
felixfontein added a commit to ansible-collections/community.docker that referenced this issue Oct 8, 2023
* vendored Docker SDK for Python code: volume: added support for bind propagation

https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation

Cherry-picked from docker/docker-py@bea6322

Co-authored-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>

* vendored Docker SDK for Python code: fix: eventlet compatibility

Check if poll attribute exists on select module instead of win32 platform check

The implementation done in #2865 is breaking usage of docker-py library within eventlet.
As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (eventlet/eventlet#608 (comment)), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`.

Fixes docker/docker-py#3131

Cherry-picked from docker/docker-py@78439eb

Co-authored-by: Mathieu Virbel <mat@meltingrocks.com>

* vendored Docker SDK for Python code: fix: use response.text to get string rather than bytes

Adjusted from docker/docker-py@0618951

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>

* vendored Docker SDK for Python code: Fix missing asserts or assignments

Cherry-picked from docker/docker-py@0566f12

Co-authored-by: Aarni Koskela <akx@iki.fi>

---------

Co-authored-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
Co-authored-by: Mathieu Virbel <mat@meltingrocks.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Aarni Koskela <akx@iki.fi>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant