Skip to content

Commit

Permalink
Allow poll_callback return value to stop polling loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Jun 15, 2023
1 parent e470fd3 commit 574ed58
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion law/workflow/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,12 @@ def poll(self):
raise Exception(err.format(self.poll_data.n_finished_min, n_jobs, n_failed))

# invoke the poll callback
self._get_task_attribute("poll_callback", True)(self.poll_data)
poll_callback_res = self._get_task_attribute("poll_callback", True)(self.poll_data)
if poll_callback_res is False:
logger.debug(
"job polling loop gracefully stopped due to False returned by poll_callback",
)
break

# trigger automatic resubmission and submission of unsubmitted jobs if necessary
if retry_jobs or self.poll_data.n_active < self.poll_data.n_parallel:
Expand Down Expand Up @@ -1363,6 +1368,9 @@ def poll_callback(self, poll_data):
Configurable callback that is called after each job status query and before potential
resubmission. It receives the variable polling attributes *poll_data* (:py:class:`PollData`)
that can be changed within this method.
If *False* is returned, the polling loop is gracefully terminated. Returning any other value
does not have any effect.
"""
return

Expand Down

0 comments on commit 574ed58

Please sign in to comment.