-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stream issues in container.top #250
Conversation
yield json.loads(entry) | ||
else: | ||
yield entry | ||
return json.loads(response.content) if decode else response.content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behaviour of stats() to read all the contents before returning the JSON payload. Given there is a streaming flag I don't see this change as wrong, just potentially breaking for developers who may be using the previous implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in loading the response was made in 3ad81a7
It has already been merged in #237 and released. 😅
Also the existing code before that had issues for non-stream mode, where it was encoding each character in the response with an \n
appended. I ended up replacing it with a simple json.loads
.
Snippet for Ref:
with io.StringIO() as buffer:
for entry in response.text:
buffer.write(json.dumps(entry) + "\n")
return buffer.getvalue()
Please feel free to suggest any better alternatives.
I'll make the required changes.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jwhonce, RazCrimson The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM if @rhatdan and @jwhonce are happy. @RazCrimson might wanna squash commits? |
1ab7515
to
7a9d1ed
Compare
@lsm5 |
i was just checking if you needed / wanted to squash at all :) . Either way is fine by me. Also, there's a ModuleNotFoundError now :( |
7a9d1ed
to
3d8eb1b
Compare
Weird, there are no actual changes in the files before and after squashing. Triggering another build did not fix it too. Any ideas? 🤔 |
@cevich any idea whatsup with the fedora-37 failure? |
Probably need to add extras into the requirements. It was removed from |
Fixing CI via #252 |
@mwhahaha thanks! @RazCrimson rebasing should make CI green. |
include: tests for `stream_helper` and typing fixes in test_parse_utils.py Signed-off-by: Raz Crimson <[email protected]>
Signed-off-by: Raz Crimson <[email protected]>
fixes: Container.top - infinite blocking when stream=True - inconsistent decoding to json add: test for Container.top with stream=True to avoid regression Signed-off-by: Raz Crimson <[email protected]>
3d8eb1b
to
2438096
Compare
@lsm5 Done! |
LGTM |
Changes:
stream_helper
to stream and decode json responsesThe
stream_helper
would be useful when other APIs require streaming and JSON decoding like for the API mentioned in #239Please do let me know in case something needs to be changed or amended.
Closes #249