Skip to content

Commit

Permalink
Merge remote-tracking branch 'richtja/interript_fix'
Browse files Browse the repository at this point in the history
Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Jun 23, 2023
2 parents d482e34 + ccb460d commit b447876
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions avocado/core/task/statemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, tasks, status_repo):
self._finished = []
self._lock = asyncio.Lock()
self._cache_lock = asyncio.Lock()
self._task_size = len(tasks)

self._tasks_by_id = {
str(runtime_task.task.identifier): runtime_task.task
Expand Down Expand Up @@ -62,6 +63,10 @@ def lock(self):
def cache_lock(self):
return self._cache_lock

@property
def task_size(self):
return self._task_size

@property
async def complete(self):
async with self._lock:
Expand Down Expand Up @@ -441,15 +446,17 @@ async def _terminate_tasks(self, task_status):
await self._state_machine.abort(task_status)
terminated = []
while True:
is_complete = await self._state_machine.complete
async with self._state_machine.lock:
try:
runtime_task = self._state_machine.monitored.pop(0)
await self._terminate_task(runtime_task, task_status)
terminated.append(runtime_task)
except IndexError:
if is_complete:
if (
len(self._state_machine.finished) + len(terminated)
== self._state_machine.task_size
):
break
await self._terminate_task(runtime_task, task_status)
terminated.append(runtime_task)
return terminated

async def terminate_tasks_timeout(self):
Expand Down

0 comments on commit b447876

Please sign in to comment.