-
Notifications
You must be signed in to change notification settings - Fork 6
Process unfinished jobs at startup #24
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -760,6 +760,20 @@ def do_work(self): | |||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # clear out retrieved but unprocessed work | ||||||||||||||||||||||||||
| self.__logger.debug("Process any leftover local jobs") | ||||||||||||||||||||||||||
| self.__queue_monitor_output_lock.release() | ||||||||||||||||||||||||||
| for target_dir, target_queue in ( | ||||||||||||||||||||||||||
| (SUCCESS_DIR, self.__successful_job_queue), | ||||||||||||||||||||||||||
| (FAILED_DIR, self.__failed_job_queue), | ||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||
| for job in os.listdir(target_dir): | ||||||||||||||||||||||||||
| target_queue.put(os.path.join(target_dir, job)) | ||||||||||||||||||||||||||
|
Comment on lines
+770
to
+771
|
||||||||||||||||||||||||||
| for job in os.listdir(target_dir): | |
| target_queue.put(os.path.join(target_dir, job)) | |
| try: | |
| for job in os.listdir(target_dir): | |
| job_path = os.path.join(target_dir, job) | |
| if os.path.isdir(job_path): | |
| target_queue.put(job_path) | |
| except Exception as e: | |
| self.__logger.error( | |
| "Error processing leftover jobs in directory '%s': %s", target_dir, e | |
| ) | |
| self.__logger.error(traceback.format_exc()) |
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.
Adding error handling is a good idea, even if only so we can output a more specific logging message before re-throwing the exception, but I'll leave it up to you to decide if it's worth it here. If not, please add an issue so we don't forget to revisit this.
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.
Aside from the error handling what are your thoughts on only processing directories or some other kind of filtration for entries in the target directories?
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 we don't filter directory names when processing them normally, I don't think we need to do it here. If we do, then we should filter similarly here. Not a bad idea to add a TODO issue to filter in both places though.
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.
We do not filter normally, but we also do not iterate over directory contents normally. The normal operation would simply ignore any directories that the commander itself did not put into the two directories while it is running.
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.
Then it's probably safest to filter so that we only process directories that match our expected pattern.
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.
To match verbiage in my other suggestion:
| self.__logger.debug("Finished processing leftover jobs") | |
| self.__logger.debug("Finished processing previously-unprocessed jobs") |
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 prefer this verbiage to "leftover", but feel free to ignore: