class_docstr: Wrap gc.collect to protect against excessively repeated calls.
  
  Allows to run throttled garbage collection in the workers as a
  countermeasure to e.g.: https://github.com/dask/zict/issues/19
  
  collect() does nothing when repeated calls are so costly and so frequent
  that the thread would spend more than max_in_gc_frac doing GC.
  
  warn_if_longer is a duration in seconds (10s by default) that can be used
  to log a warning level message whenever an actual call to gc.collect()
  lasts too long.
class_docstr_tok: ["Wrap","gc.collect","to","protect","against","excessively","repeated","calls",".","Allows","to","run","throttled","garbage","collection","in","the","workers","as","a","countermeasure","to","e.g",".",":","https",":","\/\/github.com\/dask\/zict\/issues\/19","collect","(",")","does","nothing","when","repeated","calls","are","so","costly","and","so","frequent","that","the","thread","would","spend","more","than","max_in_gc_frac","doing","GC",".","warn_if_longer","is","a","duration","in","seconds","(","10s","by","default",")","that","can","be","used","to","log","a","warning","level","message","whenever","an","actual","call","to","gc.collect","(",")","lasts","too","long","."]
code: def __init__(
      self, max_in_gc_frac=0.05, warn_if_longer=1, logger=None
  ):
      self.max_in_gc_frac = max_in_gc_frac
      self.warn_if_longer = warn_if_longer
      self.last_collect = thread_time()
      self.last_gc_duration = 0
      self.logger = logger if logger is not None else _logger
  
imports: from __future__ import annotations
  import gc
  import logging
  import threading
  from collections import deque
  import psutil
  from dask.utils import format_bytes
  from distributed.metrics import thread_time
label_desc: Use image node_id 1 to create a new ThrottledGC object  with example: obj = ThrottledGC(max_in_gc_frac, warn_if_longer, logger)