Merge pull request #4255 from omChauhanDev/fix/async-gc-collect
PipelineRunner: make _gc_collect async
This commit is contained in:
1
changelog/4255.fixed.md
Normal file
1
changelog/4255.fixed.md
Normal 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.
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user