-
Notifications
You must be signed in to change notification settings - Fork 464
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
Add support for cron jobs in ARQ integration #2088
Add support for cron jobs in ARQ integration #2088
Conversation
assert error_event["exception"]["values"][0]["mechanism"]["type"] == "arq" | ||
loop = asyncio.get_event_loop() | ||
task = loop.create_task(worker.async_run()) | ||
await asyncio.sleep(1) |
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.
This is needed because the cron job automatically execute after the worker
starts.
There's no way to actually wait for a cron job to finish other than adding some delay before asserting results.
Hey @lewazo ! |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
ping |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
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.
Nice work!
Looks good to me, and does what it should!
Btw @lewazo and @iam-abbas Sentry has now a "Crons" feature, where cron jobs can submit their config (when it should run) on creation of a cron job and then can have check ins on each run (and on each success and failure) and then one has a nice UI in Sentry to see if the crons are running on time and if there are errors. Here is part of the implementation in Celery: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/celery.py#L500-L518 Maybe you want to add this too for ARQ? |
Thanks @antonpirker that looks like a nice feature indeed and sounds perfect for this integration. I'll reserve some time to take a look at implementing it for ARQ |
This adds support for logging exceptions that occurs in ARQ cron jobs to Sentry.
Previously, only the tasks defined in the functions argument of the ARQ Worker Settings class were supported. Cron jobs were being ignored.
Since Cron Jobs run automatically by the
worker
object, we need to patch theworker
instead of thefunc
function that was previously patched.