Merge pull request #4255 from omChauhanDev/fix/async-gc-collect

PipelineRunner: make _gc_collect async
This commit is contained in:
Aleix Conchillo Flaqué
2026-04-09 12:09:38 -07:00
committed by GitHub
2 changed files with 4 additions and 3 deletions

1
changelog/4255.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed `PipelineRunner._gc_collect()` blocking the event loop by running `gc.collect()` synchronously. Now offloaded via `asyncio.to_thread` to avoid stalling concurrent pipeline tasks.

View File

@@ -90,7 +90,7 @@ class PipelineRunner(BaseObject):
await self._sig_task
if self._force_gc:
self._gc_collect()
await self._gc_collect()
logger.debug(f"Runner {self} finished running {task}")
@@ -136,8 +136,8 @@ class PipelineRunner(BaseObject):
logger.warning(f"Interruption detected. Cancelling runner {self}")
await self.cancel()
def _gc_collect(self):
async def _gc_collect(self):
"""Force garbage collection and log results."""
collected = gc.collect()
collected = await asyncio.to_thread(gc.collect)
logger.debug(f"Garbage collector: collected {collected} objects.")
logger.debug(f"Garbage collector: uncollectable objects {gc.garbage}")