-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add progress callback support to Payload #12340
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
Open
mib1185
wants to merge
8
commits into
aio-libs:master
Choose a base branch
from
mib1185:add-progress-callback-to-payload-writer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+203
−6
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
75f7cba
add progress callback support to Payload
mib1185 a52fe2f
add change log fragment
mib1185 8a99955
fix BytesIOPayload progress reporting
mib1185 a27ac60
fix AsyncIterablePayload progress reporting
mib1185 f6ae757
fix total_written_len for content length limited chunked writes
mib1185 c1de28d
add tests
mib1185 d55d52f
add type annotations to tests
mib1185 95479eb
make flake8 happy
mib1185 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Added the possibility to provide a callback to the ``Payload``, | ||
| which is used by their writer methods to report back the already written bytes. | ||
| -- by :user:`mib1185`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure, if it make sense to add the progress callback support to payloads which doesn't support chunked writing?
Uh oh!
There was an error while loading. Please reload this page.
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 also misses the .write() method. I feel like such a thing should probably be in the writer instead..?
I'm also wondering if you need a callback, or whether you can already achieve this using writer.output_size?
And if we do decide to go with a callback, should we put it in writer.drain() so it's updated once the bytes have finished sending, instead of before?
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.
In particular here, I'm trying to think of performance. If we're uploading 1 GB and this callback gets called every 1 KB, that's going to be a lot of CPU churn. In that case, you'd be better just running a task that reads the attribute every second or so.
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm using the described approach from Sending Multipart Requests in the synology dsm lib here and TBH I've no clue how to reach the mentioned
writer.output_sizeproperty. Any hint how to reach this property would highly be appreciated and the need of this PR would also be gone 😬Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, looking through, it looks like the only semi-reasonable way to reach it currently would be to use a middleware and extract
request._writerfrom there. Definitely looks like we should do something to expose it more easily..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.
Also probably possible to use the tracing API and track how much data is sent through on_request_chunk_sent: https://docs.aiohttp.org/en/stable/client_advanced.html#aiohttp-client-tracing
Though still not convinced that's the best option for you.
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.
I'll get @bdraco's thoughts on it too and see if what plan we can come up with.