class_docstr: Cache for data handlers that keep connections opened during ttl time from handler last use
      
class_docstr_tok: ["Cache","for","data","handlers","that","keep","connections","opened","during","ttl","time","from","handler","last","use"]
docstr: worker that delete from cache handlers that was not in use for ttl
          
code: def _clean(self) -> None:
      """worker that delete from cache handlers that was not in use for ttl"""
      while self._stop_event.wait(timeout=3) is False:
          with self._lock:
              for key in list(self.handlers.keys()):
                  if (
                      self.handlers[key]["expired_at"] < time()
                      and sys.getrefcount(self.handlers[key])
                      == 2  # returned ref count is always 1 higher
                  ):
                      try:
                          self.handlers[key].disconnect()
                      except Exception:
                          pass
                      del self.handlers[key]
              if len(self.handlers) == 0:
                  self._stop_event.set()
  
imports: import os
  import sys
  import base64
  import shutil
  import tempfile
  import importlib
  import threading
  import inspect
  import multiprocessing
  from time import time
  from pathlib import Path
  from copy import deepcopy
  from typing import Optional
  from textwrap import dedent
  from collections import OrderedDict
  from sqlalchemy import func
  from mindsdb.interfaces.storage import db
  from mindsdb.utilities.config import Config
  from mindsdb.interfaces.storage.fs import FsStore, FileStorage, RESOURCE_GROUP
  from mindsdb.interfaces.storage.model_fs import HandlerStorage
  from mindsdb.interfaces.file.file_controller import FileController
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb.integrations.libs.base import BaseMLEngine
  from mindsdb.integrations.libs.api_handler import APIHandler
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE, HANDLER_TYPE
  from mindsdb.integrations.handlers_client.db_client_factory import DBClient
  from mindsdb.interfaces.model.functions import get_model_records
  from mindsdb.utilities.context import context
  from mindsdb.utilities import log
  from mindsdb.integrations.libs.ml_exec_base import BaseMLEngineExec
  import mindsdb.utilities.profiler
label_desc: Use image node_id 8 for calling the HandlersCache obj's underlying member method code with example usage: obj._clean() without return types