class_docstr: simple cache for WarmProcess-es
      
class_docstr_tok: ["simple","cache","for","WarmProcess-es"]
docstr: worker that stop unused processes
          
docstr_tok: ["worker","that","stop","unused","processes"]
code: def _clean(self) -> None:
      """worker that stop unused processes"""
      while self._stop_event.wait(timeout=10) is False:
          with self._lock:
              for handler_name in self.cache.keys():
                  processes = self.cache[handler_name]["processes"]
                  processes.sort(key=lambda x: x.is_marked())
  
                  expected_count = 0
                  if handler_name in self._keep_alive:
                      expected_count = self._keep_alive[handler_name]
  
                  # stop processes which was used, it needs to free memory
                  for i, process in enumerate(processes):
                      if (
                          process.ready()
                          and process.is_marked()
                          and (time.time() - process.last_usage_at)
                          > self._ttl
                      ):
                          processes.pop(i)
                          # del process
                          process.shutdown()
                          break
  
                  while expected_count > len(processes):
                      processes.append(
                          WarmProcess(
                              init_ml_handler,
                              (
                                  self.cache[handler_name][
                                      "handler_module"
                                  ],
                              ),
                          )
                      )
  
imports: import sys
  import time
  import threading
  from typing import Optional, Callable
  from concurrent.futures import ProcessPoolExecutor, Future
  from pandas import DataFrame
  from mindsdb.utilities.config import Config
  from mindsdb.utilities.context import context
  from mindsdb.utilities.ml_task_queue.const import ML_TASK_TYPE
  from mindsdb.integrations.libs.learn_process import learn_process, predict_process
label_desc: Use image node_id 7 for calling the ProcessCache obj's underlying member method code with example usage: obj._clean() without return types