Skip to content

Commit 6ce4bd6

Browse files
committed
add improved debugging for asyncio hanging
1 parent 882c4f0 commit 6ce4bd6

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

avocado_i2n/plugins/runner.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,24 @@ def run_workers(self, test_suite: TestSuite | TestGraph, params: Params) -> None
342342
raise RuntimeError(f"Failed to start environment {worker.id}")
343343
slot_workers = sorted([*graph.workers.values()], key=lambda x: x.params["name"])
344344
to_traverse = [graph.traverse_object_trees(s, params) for s in slot_workers]
345-
asyncio.get_event_loop().run_until_complete(
346-
asyncio.wait_for(asyncio.gather(*to_traverse), self.job.timeout or None)
347-
)
345+
try:
346+
asyncio.get_event_loop().run_until_complete(
347+
asyncio.wait_for(
348+
asyncio.shield(asyncio.gather(*to_traverse)),
349+
86400 or self.job.timeout or None,
350+
)
351+
)
352+
except asyncio.TimeoutError as error:
353+
logging.error(error)
354+
import stackscope
355+
logging.critical("Timeout exceeded. Printing stacks of all running coroutines:")
356+
all_coros = [t.get_coro() for t in asyncio.all_tasks()]
357+
for coro in all_coros:
358+
logging.critical(stackscope.extract(coro))
359+
except KeyboardInterrupt as error:
360+
logging.info(str(error))
361+
self.job.interrupted_reason = str(error)
362+
#summary.add("INTERRUPTED")
348363

349364
def run_suite(self, job: Job, test_suite: TestSuite) -> set[str]:
350365
"""

0 commit comments

Comments
 (0)