-
Notifications
You must be signed in to change notification settings - Fork 49
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
Refactor Handlers for None
-correctness
#1581
Comments
Follow-up from arch: Another option to handle this situation is to not instantiate a handler in |
This comment was marked as resolved.
This comment was marked as resolved.
Move job handler's pre-checks in a new class Job handlers should be retriable and may have a CeleryTask reference. If a job handler is instantiated just for calling the pre-check method then it can not be given a CeleryTask reference. The pre_check method is now a classmethod for any job handler. The job handler's pre_check method will invoke the pre_check method of a list of new checker classes. A checker class needs all the parameters needed by a job handler class but it does not need the CeleryTask reference. All the common code between checkers and handlers has been moved in mixin classes. Fixes #1581 Reviewed-by: None <None> Reviewed-by: František Nečas <[email protected]> Reviewed-by: Maja Massarini <None> Reviewed-by: Laura Barcziová <None> Reviewed-by: Matej Focko <None>
Follow up of the discussion with @lbarcziova in #1579 (comment)
Currently, handlers are instantiated in 2 times, once in
Steve
and then in the celery task corresponding to the handler. However, the use-cases for these two initializations are different:Steve
just usespre_check()
and perhaps some other stuff but doesn't run itThis causes problems with regards to
None
correctness as explained in the comment linked above. Ideally, a task that can be retried should not have itsCeleryTask
argument set toNone
(without the task attached, retrying is not possible and does not make sense). However, the initialization insideSteve
does not have a celery task yet to attach, hence it must be set toNone
(a bit of a chicken-egg problem).A solution that I assume could work (however, feel free to come up with anything else):
pre_check
and similar stuffrun
and inherits fromBaseHandler
Steve
initialize just the BaseHandler which does not need aCeleryTask
even for a retriable job handler.CeleryTask
argumentThis is a blocker for #1433 (the implementation from #1579 would not pass mypy's strict checks -- however it does not make sense to block it on this rather large refactoring)
The text was updated successfully, but these errors were encountered: