Skip to content
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

NEW: generator hooks ✨ #68

Merged
merged 1 commit into from
Jan 26, 2024
Merged

NEW: generator hooks ✨ #68

merged 1 commit into from
Jan 26, 2024

Conversation

eigenein
Copy link
Member

Motivation

I need to add some custom metric based on when exactly the decorated function got called: a background job start delay after its scheduled execution time.

Implementation

In addition to simple functions, the decorator now accepts generator functions. That would allow them to run some code just before the decorated function gets called and remember the state.

Plain old hooks are not affected. The change is designed to be backwards-compatible.

@eigenein eigenein self-assigned this Jan 25, 2024
@eigenein eigenein force-pushed the new/generator-hooks branch 2 times, most recently from b731ab9 to 3ecbe6f Compare January 25, 2024 15:25
@scastlara
Copy link

This is quite complex to get your head around, do you think it deserves some mention in the docs/readme?

@eigenein eigenein force-pushed the new/generator-hooks branch 2 times, most recently from c7119fb to 865abe1 Compare January 26, 2024 10:59
### Motivation

I need to add some custom metric based on when exactly the decorated function got called: a background job start delay after its scheduled execution time.

### Implementation

In addition to simple functions, the decorator now accepts generator functions. That would allow them to run some code just before the decorated function gets called and remember the state.

Plain old hooks are not affected. The change is designed to be backwards-compatible.
@eigenein eigenein force-pushed the new/generator-hooks branch from 865abe1 to f982302 Compare January 26, 2024 11:02
@eigenein
Copy link
Member Author

Got verbal approvals, force-merging it

@eigenein eigenein merged commit 4bbaf21 into master Jan 26, 2024
6 checks passed
@eigenein eigenein deleted the new/generator-hooks branch January 26, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants