Kaydet (Commit) a102b189 authored tarafından Maxime Petazzoni's avatar Maxime Petazzoni

Fix events() streaming by using _stream_helper()

Signed-off-by: 's avatarMaxime Petazzoni <max@signalfuse.com>
üst 45cde4a0
...@@ -450,20 +450,7 @@ class Client(requests.Session): ...@@ -450,20 +450,7 @@ class Client(requests.Session):
format(container))), True) format(container))), True)
def events(self): def events(self):
socket = self._get_raw_response_socket(self.get(self._url('/events'), return self._stream_helper(self.get(self._url('/events'), stream=True))
stream=True))
while True:
chunk = socket.recv(4096)
if chunk:
# Messages come in the format of length, data, newline.
# XXX: do they really?
length, data = chunk.split("\n", 1)
length = int(length, 16)
if length > len(data):
data += socket.recv(length - len(data))
yield json.loads(data)
else:
break
def export(self, container): def export(self, container):
if isinstance(container, dict): if isinstance(container, dict):
......
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