Skip to content

Commit

Permalink
fix AsyncioServiceMixin finalization: background tasks can be in st…
Browse files Browse the repository at this point in the history
…ate `done`, but callback can be not called yet
  • Loading branch information
pohmelie committed Apr 25, 2024
1 parent 221e3ea commit 7cf267f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/facet/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ async def __start_dependencies(self) -> None:
await self.__wait_with_cancellation_on_fail(starts)

async def __stop_dependencies(self) -> None:
stops = []
for task in self.__ensure_tasks():
background_tasks = self.__ensure_tasks()
for task in background_tasks:
if not task.done():
task.cancel()
stops.append(task)
if stops:
await wait(stops)
if background_tasks:
await wait(background_tasks)
for group in reversed(self.dependencies):
if isinstance(group, AsyncioServiceMixin):
group = [group]
Expand Down

0 comments on commit 7cf267f

Please sign in to comment.