Skip to content

Introduce @after_completed_request decorator #290

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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mirko
Copy link

@mirko mirko commented Mar 18, 2025

In some situations code might want to be executed after the request was handled and completed. The completed part is what makes it different to the already existing @after_request decorator, which respectively decorated functions are executed after the request was handled, but still before the HTTP client's request was being responded to.

@mirko mirko force-pushed the add-after_completed_req-decorator branch from e2b378d to 50d5245 Compare March 18, 2025 21:25
@mirko
Copy link
Author

mirko commented Mar 18, 2025

(Initial) discussion: #289

for handler in self.get_request_handlers(
req, 'after_completed_request', True):
res = await invoke_handler(
handler) or res
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the point of res here? You aren't passing any arguments to this handler, and you aren't doing anything with the return value, so why have it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, copy & paste - guess i should have waited for after a good night's sleep and actually review and understand the lines i just copied from elsewhere.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force-pushed addressing this

In some situations code might want to be executed after the request was
handled *and completed*. The completed part is what makes it different
to the already existing @after_request decorator, which respectively
decorated functions are executed after the request was handled, but
still before the HTTP client's request was being responded to.
@mirko mirko force-pushed the add-after_completed_req-decorator branch from 50d5245 to 3d3b644 Compare March 19, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants