Skip to content

Cannot use docker with eventlet since #2865 #3131

@tito

Description

@tito

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   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions