Add progress callback support to Payload#12340
Add progress callback support to Payload#12340mib1185 wants to merge 8 commits intoaio-libs:masterfrom
Conversation
❌ 3 Tests Failed:
View the top 1 failed test(s) by shortest run time
View the full list of 2 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
Merging this PR will not alter performance
Comparing Footnotes
|
| is performed efficiently using array slicing. | ||
|
|
||
| """ | ||
| self._report_progress(0) |
There was a problem hiding this comment.
I'm not sure, if it make sense to add the progress callback support to payloads which doesn't support chunked writing?
There was a problem hiding this comment.
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.
I'm also wondering if you need a callback, or whether you can already achieve this using writer.output_size?
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.
There was a problem hiding this comment.
or whether you can already achieve this using writer.output_size?
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_size property. Any hint how to reach this property would highly be appreciated and the need of this PR would also be gone 😬
What do these changes do?
This adds the possibility to provide a callback to the
Payloadclass, which is used by their writer methods to report back the already written bytes. The intention is, that a consuming application can get a progress indication - in my specific case, I want to add the backup upload progress to the Synology DSM integration in Home Assistant. The Synology DSM uses the aiohttp client with the MultipartWriter to perform the upload. The goal is to provide the callback like:todo:
Are there changes in behavior for the user?
No, as the callback is set to
Noneby defaultIs it a substantial burden for the maintainers to support this?
I don't think so.
Related issue number
Checklist
CONTRIBUTORS.txtCHANGES/foldername it
<issue_or_pr_num>.<type>.rst(e.g.588.bugfix.rst)if you don't have an issue number, change it to the pull request
number after creating the PR
.bugfix: A bug fix for something the maintainers deemed animproper undesired behavior that got corrected to match
pre-agreed expectations.
.feature: A new behavior, public APIs. That sort of stuff..deprecation: A declaration of future API removals and breakingchanges in behavior.
.breaking: When something public is removed in a breaking way.Could be deprecated in an earlier release.
.doc: Notable updates to the documentation structure or buildprocess.
.packaging: Notes for downstreams about unobvious side effectsand tooling. Changes in the test invocation considerations and
runtime assumptions.
.contrib: Stuff that affects the contributor experience. e.g.Running tests, building the docs, setting up the development
environment.
.misc: Changes that are hard to assign to any of the abovecategories.
Make sure to use full sentences with correct case and punctuation,
for example:
Use the past tense or the present tense a non-imperative mood,
referring to what's changed compared to the last released version
of this project.