Skip to content

Commit b061fce

Browse files
committed
Checking existence and then deleting is not atomic, so try to delete and
ignore FileNotFoundError instead
1 parent aeecc27 commit b061fce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/psij/executors/batch/batch_scheduler_executor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,12 @@ def _clean_submit_script(self, job: Job) -> None:
541541
assert isinstance(self.config, BatchSchedulerExecutorConfig)
542542
if not self.config.keep_files:
543543
submit_file_path = self.work_directory / (job.id + '.job')
544-
if submit_file_path.exists():
544+
try:
545545
submit_file_path.unlink()
546+
except FileNotFoundError:
547+
# this can reasonably happen for attached jobs when the main
548+
# job cleans up the script instead
549+
pass
546550
except Exception as ex:
547551
logger.warning('Job %s: failed clean submit script: %s', job.id, ex)
548552

0 commit comments

Comments
 (0)