-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Improves after_job_end hook #409
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #409 +/- ##
==========================================
- Coverage 98.40% 98.31% -0.09%
==========================================
Files 11 11
Lines 1063 1071 +8
Branches 200 201 +1
==========================================
+ Hits 1046 1053 +7
Misses 8 8
- Partials 9 10 +1
Continue to review full report in Codecov by Sentry.
|
@AngellusMortis hi there 👋 I am taking advantage of your deeper knowledge regarding this hook. question: without this PR the hook If that is the case, would there be a work around using other hooks ? Thanks in advance |
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.
In general looks good, mostly just needs some docstrings.
async def job_failed(exc: BaseException, ref: Optional[str] = None) -> None: | ||
ref = ref or f'{job_id}:{function_name}' |
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.
async def job_failed(exc: BaseException, ref: Optional[str] = None) -> None: | |
ref = ref or f'{job_id}:{function_name}' | |
async def job_failed(exc: BaseException, ref: str = f'{job_id}:{function_name}') -> None: |
@@ -701,6 +687,12 @@ async def finish_job( | |||
tr.delete(*delete_keys) # type: ignore[unused-coroutine] | |||
await tr.execute() | |||
|
|||
async def _after_job_end(self, ctx: Dict[Any, Any], job_result: Optional[JobResult]) -> None: |
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.
please add a docstring.
queue_name: str, | ||
*, | ||
serializer: Optional[Serializer] = None, | ||
) -> Tuple[JobResult, Optional[bytes]]: |
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.
please add a docstring explaining what this does.
I no longer care. |
Since
finish_job
can fail, I adjusted theafter_job_end
hook to always receive a copy of the theJobResult
that would get written into redis.I also updated all of the other places that recorded a failing job to call
after_job_end
as well and added aasyncio.shield
toafter_job_end
as it is a great way to do something with the job result (like generate metrics for New Relic/Prometheus/etc.).