Skip to content

Commit

Permalink
Fix formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Nov 11, 2024
1 parent de27ea0 commit b4d99cc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/schains/monitor/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def execute_tasks(
process_report: ProcessReport,
sleep_interval: int = SLEEP_INTERVAL_SECONDS,
) -> None:
logger.info("Running tasks %s", tasks)
with ThreadPoolExecutor(max_workers=len(tasks), thread_name_prefix="T") as executor:
logger.info('Running tasks %s', tasks)
with ThreadPoolExecutor(max_workers=len(tasks), thread_name_prefix='T') as executor:
stucked = []
while True:
for index, task in enumerate(tasks):
logger.info(
"Status of %s, running: %s needed: %s stucked: %s",
'Status of %s, running: %s needed: %s stucked: %s',
task.name,
task.future.running(),
task.needed,
Expand All @@ -74,21 +74,21 @@ def execute_tasks(
logger.info('Done')
logger.info('Result %s', task.future.result())

Check warning on line 75 in core/schains/monitor/tasks.py

View check run for this annotation

Codecov / codecov/patch

core/schains/monitor/tasks.py#L74-L75

Added lines #L74 - L75 were not covered by tests
task.start_ts = int(time.time())
logger.info("Starting task %s at %d", task.name, task.start_ts)
logger.info('Starting task %s at %d', task.name, task.start_ts)
task.future = executor.submit(task.run)
elif task.future.running():
if int(time.time()) - task.start_ts > task.stuck_timeout:
logger.info("Canceling future for %s", task.name)
logger.info('Canceling future for %s', task.name)
canceled = task.future.cancel()
if not canceled:
logger.warning("Stuck detected for job %s", task.name)
logger.warning('Stuck detected for job %s', task.name)
task.start_ts = -1
stucked.append(task.name)
time.sleep(sleep_interval)
if len(stucked) > 0:
logger.info("Sleeping before subverting execution")
logger.info('Sleeping before subverting execution')
executor.shutdown(wait=False)
logger.info("Subverting execution. Stucked %s", stucked)
logger.info('Subverting execution. Stucked %s', stucked)
process_report.ts = 0
break
process_report.ts = int(time.time())

0 comments on commit b4d99cc

Please sign in to comment.