Skip to content

Socket timeout in python2 #2425

Closed
Closed
@jliu90

Description

  • OS: MacOS 10.14.5
  • python: 2.7.14
  • docker/docker-py version:
pip freeze | grep docker && python --version && docker version
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
docker==3.2.0
docker-compose==1.20.0
docker-pycreds==0.4.0
dockerpty==0.4.1
Python 2.7.14
Client: Docker Engine - Community
 Version:           19.03.1
 API version:       1.40
 Go version:        go1.12.5
 Git commit:        74b1e89
 Built:             Thu Jul 25 21:18:17 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.1
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.5
  Git commit:       74b1e89
  Built:            Thu Jul 25 21:17:52 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Description:

I use docker-compose to start 3 containers, one of them being a web server. The web server
prints some debug info to stdout when processing requests.

I was on a very old docker-py version (2.2.1) but it has been working fine. I recently upgraded to docker-py 3.7.3 and realized that docker-compose is not printing anything if the web server has been idle for a while. Tried to find a threshold of idle time and it's about 60 seconds.

I went on and tried multiple docker-py versions. The latest version that works fine is 3.1.4. I looked the diff between version 3.2.0 and 3.1.4, and found this:
(line 25 in docker/utils/socket.py in 284c3d9)

if six.PY3 and not isinstance(socket, NpipeSocket):
    if not isinstance(socket, NpipeSocket):	
        select.select([socket], [], [])	        select.select([socket], [], [])

Looks like it's not doing the select.select in python2, hence the socket times out after 60 seconds in read().
I switched to 3.2.0, removed the condition for six.PY3 and it works perfectly fine.

So my question is: is there a reason why docker-py only do the select.select call in python3? If there's a good reason we can't do it python2, is there anything a docker-compose user can do to avoid socket timeout? Should that be a docker-compose issue?

(This docker-compose issue may be related docker/compose#6261)

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