-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from juaml/fix/retry_lock
Retry lock of DelayedSubmission if a timeout occurs
- Loading branch information
Showing
4 changed files
with
73 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Retry load/dump of the DelayedSubmission object in case a TimeOutError from the flufl.lock is raised |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# Synchon Mandal <[email protected]> | ||
# License: AGPL | ||
|
||
import time | ||
from datetime import datetime | ||
|
||
|
||
|
@@ -103,7 +104,15 @@ def logger_level(arg): | |
|
||
# Load file | ||
logger.info(f"Loading DelayedSubmission object from {fname}") | ||
ds = DelayedSubmission.load(fname) | ||
ds = None | ||
while ds is None: | ||
ds = DelayedSubmission.load(fname) | ||
if ds is None: | ||
logger.warning( | ||
f"Could not load DelayedSubmission object from {fname}. " | ||
"Retrying in 1 second." | ||
) | ||
time.sleep(1) # Wait 1 second before retrying | ||
|
||
# Issue warning for re-running | ||
if ds.done(): | ||
|
@@ -119,5 +128,13 @@ def logger_level(arg): | |
out_fname = fname.with_stem(f"{old_stem}_out") | ||
logger.info(f"Dumping DelayedSubmission (result only) to {out_fname}") | ||
# Dump output | ||
ds.dump(out_fname, result_only=True) | ||
dumped = False | ||
while not dumped: | ||
dumped = ds.dump(out_fname, result_only=True) | ||
if not dumped: | ||
logger.warning( | ||
f"Could not dump DelayedSubmission to {out_fname}. " | ||
"Retrying in 1 second." | ||
) | ||
time.sleep(1) | ||
logger.info("Done.") |