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.
Safe async event cache #13308
Safe async event cache #13308
Changes from 9 commits
6beae64
65b47e1
87001f8
c170748
be84644
9ef18e4
e90f402
b8ea213
d39d9bf
a2d2312
bd174cc
e71ac4a
22f114d
771c29d
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.
IMHO this second paragraph belongs as a comment rather than a docstring. It's not really the place of a docstring to describe the reasons behind implementation decisions within a method.
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.
is there a good reason to limit this to coroutine functions, rather than other awaitables? I think
inspect.isawaitable(cb)
would be better?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.
That's what I did first but
isawaitable
is only true on the return value of the function (isawaitable(cb())
) rather than the function def itself:Perhaps this should be changed to also check awaitables?
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.
oh sorry, brainfart on my part. As you say: coroutine functions aren't themselves awaitable; they return an awaitable the first time you call them.
Unfortunately, they aren't the only thing that can return awaitables (eg: old-style functions that just return a Twisted
Deferred
object) and we need to do the same thing with other such functions. And you can't tell whether that is the case (other than via typing annotations) until you call the function in question and see what you get back - which of course doesn't work here.So I think the only correct way to do this is to have separate
txn.async_call_after
which updates a separate list of async callbacks.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.
can you add some comments here please? What is going on here, and why?
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.
Added a docstring to describe it - should this be hoisted to a class method now perhaps? b8ea213
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.
or, better, a top-level function. Though I suspect the changes regarding
async_call_after
mean this function isn't going to be useful any more.