Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add periodic gc.collect() callback to workers #416

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update plugin.py: fix typo
  • Loading branch information
pfackeldey authored Nov 1, 2024
commit b9faa17f29f0f67cd868b7074919c29001d9b97a
10 changes: 5 additions & 5 deletions coffea_casa/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PeriodicGC(WorkerPlugin):
----------
freq : datetime.timedelta
The frequency of garbage collection. Default is 1ms.
tresh : int
thresh : int
The threshold memory in bytes. If the process memory exceeds this value, garbage collection is triggered. Default is 100MB.


Expand All @@ -157,15 +157,15 @@ class PeriodicGC(WorkerPlugin):
def __init__(
self,
freq: datetime.timedelta = datetime.timedelta(milliseconds=1),
tresh: int = parse_bytes("100 MB"),
thresh: int = parse_bytes("100 MB"),
) -> None:
"""
Parameters:
freq: Frequency of garbage collection in seconds. Default is 1ms.
tresh: Threshold memory in bytes. If the process memory exceeds this value, garbage collection is triggered. Default is 100MB.
thresh: Threshold memory in bytes. If the process memory exceeds this value, garbage collection is triggered. Default is 100MB.
"""
self.freq = freq
self.tresh = tresh
self.thresh = thresh

def setup(self, worker) -> None:
"""
Expand All @@ -185,5 +185,5 @@ async def _gc_collect(self) -> None:
"""
Trigger garbage collection if the process memory exceeds the threshold.
"""
if self.worker.monitor.get_process_memory() >= self.tresh:
if self.worker.monitor.get_process_memory() >= self.thresh:
gc.collect()
Loading