MCPcopy
hub / github.com/docker/docker-py / _read_from_socket

Method _read_from_socket

docker/api/client.py:424–447  ·  view source on GitHub ↗

Consume all data from the socket, close the response and return the data. If stream=True, then a generator is returned instead and the caller is responsible for closing the response.

(self, response, stream, tty=True, demux=False)

Source from the content-addressed store, hash-verified

422 yield from response.iter_content(chunk_size, decode)
423
424 def _read_from_socket(self, response, stream, tty=True, demux=False):
425 """Consume all data from the socket, close the response and return the
426 data. If stream=True, then a generator is returned instead and the
427 caller is responsible for closing the response.
428 """
429 socket = self._get_raw_response_socket(response)
430
431 gen = frames_iter(socket, tty)
432
433 if demux:
434 # The generator will output tuples (stdout, stderr)
435 gen = (demux_adaptor(*frame) for frame in gen)
436 else:
437 # The generator will output strings
438 gen = (data for (_, data) in gen)
439
440 if stream:
441 return gen
442 else:
443 try:
444 # Wait for all frames, concatenate them, and return the result
445 return consume_socket_output(gen, demux=demux)
446 finally:
447 response.close()
448
449 def _disable_socket_timeout(self, socket):
450 """ Depending on the combination of python version and whether we're

Callers 3

requestMethod · 0.80
exec_startMethod · 0.80
attachMethod · 0.80

Calls 5

frames_iterFunction · 0.85
demux_adaptorFunction · 0.85
consume_socket_outputFunction · 0.85
closeMethod · 0.45

Tested by 1

requestMethod · 0.64