MCPcopy Index your code
hub / github.com/docker/docker-py / _disable_socket_timeout

Method _disable_socket_timeout

docker/api/client.py:449–475  ·  view source on GitHub ↗

Depending on the combination of python version and whether we're connecting over http or https, we might need to access _sock, which may or may not exist; or we may need to just settimeout on socket itself, which also may or may not have settimeout on it. To avoid mi

(self, socket)

Source from the content-addressed store, hash-verified

447 response.close()
448
449 def _disable_socket_timeout(self, socket):
450 """ Depending on the combination of python version and whether we're
451 connecting over http or https, we might need to access _sock, which
452 may or may not exist; or we may need to just settimeout on socket
453 itself, which also may or may not have settimeout on it. To avoid
454 missing the correct one, we try both.
455
456 We also do not want to set the timeout if it is already disabled, as
457 you run the risk of changing a socket that was non-blocking to
458 blocking, for example when using gevent.
459 """
460 sockets = [socket, getattr(socket, '_sock', None)]
461
462 for s in sockets:
463 if not hasattr(s, 'settimeout'):
464 continue
465
466 timeout = -1
467
468 if hasattr(s, 'gettimeout'):
469 timeout = s.gettimeout()
470
471 # Don't change the timeout if it is already disabled.
472 if timeout is None or timeout == 0.0:
473 continue
474
475 s.settimeout(None)
476
477 @check_resource('container')
478 def _check_is_tty(self, container):

Calls 2

gettimeoutMethod · 0.45
settimeoutMethod · 0.45