-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Callback for Job success #969
Conversation
@iamrajhans First you need to add test cases and then you need to fix the CI conflicts before we review it |
@theodesp okay will add test cases |
@theodesp will add the test cases and fix the pipeline |
Sure go ahead! |
Codecov Report
@@ Coverage Diff @@
## master #969 +/- ##
==========================================
- Coverage 93.62% 93.59% -0.04%
==========================================
Files 22 22
Lines 2260 2343 +83
==========================================
+ Hits 2116 2193 +77
- Misses 144 150 +6
Continue to review full report at Codecov.
|
@theodesp please review |
@theodesp could you please review |
looking forward to this great feature |
@theodesp please review the changes |
@theodesp, please review the changes. |
|
@@ -950,6 +960,18 @@ def handle_exception(self, job, *exc_info): | |||
if not fallthrough: | |||
break | |||
|
|||
def success_job_callback(self,job,*exc_info): |
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.
If the job is successfully executed, there's no need to pass exc_info
as arguments.
@@ -960,6 +982,10 @@ def _get_safe_exception_string(exc_strings): | |||
exc_strings = [exc.decode("latin-1") for exc in exc_strings] | |||
return ''.join(exc_strings) | |||
|
|||
def push_job_success_handler(self,handle_func): |
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.
I don't think we need this method, you can directly call self._job_success_handlers.append()
@@ -215,6 +217,12 @@ def __init__(self, queues, name=None, default_result_ttl=DEFAULT_RESULT_TTL, | |||
self.push_exc_handler(handler) | |||
elif exception_handlers is not None: | |||
self.push_exc_handler(exception_handlers) | |||
|
|||
if isinstance(success_handlers,list): |
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.
Should check whether this is an iterable and not just a list.
@@ -232,6 +233,10 @@ def worker(cli_config, burst, logging_level, name, results_ttl, | |||
for h in exception_handler: | |||
exception_handlers.append(import_attribute(h)) | |||
|
|||
success_handlers = [] | |||
for s_h in success_handler: |
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.
for handler in success_handler:
Can you run your PR through flake 8 and address all the warnings there? |
Also, please add more comprehensive tests so we can hit the diff target. |
Closing this PR due to inactivity. |
Call function after job is completed successfully.