kpn / py-timeexecution

Time Execution: record application metrics
https://pypi.org/project/timeexecution/
Apache License 2.0
12 stars 19 forks source link

NEW: generator hooks ✨ #68

Closed eigenein closed 10 months ago

eigenein commented 10 months ago

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.

scastlara commented 10 months ago

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

eigenein commented 10 months ago

Got verbal approvals, force-merging it