Skip to content

Commit ca3cc8c

Browse files
GitHKAndrei Neagu
andauthored
🐛 Fixes flaky tests in service-library test_deferred_tasks.py (#6439)
Co-authored-by: Andrei Neagu <[email protected]>
1 parent 1d8d0e0 commit ca3cc8c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/service-library/tests/deferred_tasks/test_deferred_tasks.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import random
1010
import sys
1111
from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable
12-
from contextlib import AbstractAsyncContextManager, AsyncExitStack
12+
from contextlib import AbstractAsyncContextManager, AsyncExitStack, suppress
1313
from pathlib import Path
1414
from typing import Any, Protocol
1515

@@ -60,10 +60,12 @@ async def stop(self, *, graceful: bool = False):
6060
assert self.process is not None
6161
assert self.pid is not None
6262

63-
parent = psutil.Process(self.pid)
64-
children = parent.children(recursive=True)
65-
for child_pid in [child.pid for child in children]:
66-
psutil.Process(child_pid).kill()
63+
with suppress(psutil.NoSuchProcess):
64+
parent = psutil.Process(self.pid)
65+
children = parent.children(recursive=True)
66+
for child_pid in [child.pid for child in children]:
67+
with suppress(psutil.NoSuchProcess):
68+
psutil.Process(child_pid).kill()
6769

6870
self.process = None
6971
self.pid = None

0 commit comments

Comments
 (0)