Kaydet (Commit) b100666a authored tarafından Aanand Prasad's avatar Aanand Prasad

Remove duplicated methods from container.py

Signed-off-by: 's avatarAanand Prasad <aanand.prasad@gmail.com>
üst 73f06e33
......@@ -32,6 +32,7 @@ from .ssladapter import ssladapter
from .tls import TLSConfig
from .transport import UnixAdapter
from .utils import utils, check_resource, update_headers, kwargs_from_env
from .utils.socket import read_socket, next_packet_size
try:
from .transport import NpipeAdapter
except ImportError:
......@@ -309,37 +310,6 @@ class Client(
yield out
def _read_from_socket(self, response, stream):
def read_socket(socket, n=4096):
recoverable_errors = (
errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK
)
# wait for data to become available
select.select([socket], [], [])
try:
if hasattr(socket, 'recv'):
return socket.recv(n)
return os.read(socket.fileno(), n)
except EnvironmentError as e:
if e.errno not in recoverable_errors:
raise
def next_packet_size(socket):
data = six.binary_type()
while len(data) < 8:
next_data = read_socket(socket, 8 - len(data))
if not next_data:
return 0
data = data + next_data
if data is None:
return 0
if len(data) == 8:
_, actual = struct.unpack('>BxxxL', data)
return actual
def read_loop(socket):
n = next_packet_size(socket)
while n > 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment