This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
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.
Add a batching queue implementation. #10017
Add a batching queue implementation. #10017
Changes from 3 commits
3dcd561
e4d4bab
be46149
0316863
a72870b
d656566
066bc88
581268c
5784f78
bd923d3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
A fun trick you can do is
values, deferreds = zip(*next_values)
, doesn't really save anything here though unfortunately since you have to iterate all theDeferreds
anyway.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.
Could this cause a Deferred to have both
callback
anderrback
called on it if e.g. the seconddeferred.callback
causes an error to be raised?(I wonder if we should be guarding with
if not deferred.called
?)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 don't think
deferred.callback
should ever explode, but may as well add the guard.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 would hope not. Another option would be to move the callback calls to an
else
so that only calling the processing function is in the try clause?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 think I prefer it as it is, as then we really should always call either
.errback
or.callback
for each?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.
Right, isn't that what my suggestion guarantees though?
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.
But if
d.callback
never throws then that's the same as?
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.
Yes. 😄
If it does throw it has the benefit of causing a stack trace and letting us know about it.
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.
OK, you can ignore me. It can't throw (for the reason I thought it could):
https://github.com/twisted/twisted/blob/cae365213868e8226a055f6b5e4d2c0c89c9ab3b/src/twisted/internet/defer.py#L851-L871