Skip to content

Pass job to error handler where possible #2570

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

Closed
wants to merge 1 commit into from

Conversation

Bibo-Joshi
Copy link
Member

@Bibo-Joshi Bibo-Joshi commented Jun 24, 2021

Closes #2568 - at least partly.

For jobs that run only once, APS already drops the job from memory before reporting any exception so that we can't get it back by its ID. One could maybe try to work around that somehow by reworking some of the internals of JobQueue (bascially tell APS to run job.run(dispatcher) instead of running the callback directly, but I'm not sure if that's worth it.

That would also make it even more complicated for custom persistence solutions like the recently introduced ptbcontrib/ptb_sqlalchemy_jobstore (even though this shouldn't be the main reason to to do it)
The main use case probably is to stop repeating jobs that cause exceptions, anyway.

Because this adds a new parameter to CallbackContext.from_error, this is maybe kind of breaking if people subclassed for ContextTypes and overrode that. Anyway, not that urgent so I'll be putting it on the v14 milestone for now.

edit: We could just make tg.ext.Job callable (where job(dispatcher) just does job.run(dispatcher)). This would probably solve all of the issues mentioned above 🤔

Checklist for PRs

  • Added .. versionadded:: version, .. versionchanged:: version or .. deprecated:: version to the docstrings - did that but should be updated before merging
  • Created new or adapted existing unit tests

@Bibo-Joshi Bibo-Joshi added this to the v14 milestone Jun 24, 2021
@Bibo-Joshi
Copy link
Member Author

closing in favor of #2692

@Bibo-Joshi Bibo-Joshi closed this Oct 3, 2021
@Bibo-Joshi Bibo-Joshi deleted the job-error-handling branch October 3, 2021 11:10
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2021
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 enhancement pr description: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Pass jobs to error handlers
1 participant