From 1b18bdb978d824c307a0059796866c938ac48022 Mon Sep 17 00:00:00 2001 From: wunder957 Date: Mon, 25 Sep 2023 17:13:35 +0800 Subject: [PATCH] Fix ShTracerHost method and improve performance (#77) --- duetector/monitors/sh_monitor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/duetector/monitors/sh_monitor.py b/duetector/monitors/sh_monitor.py index b19b818..3041c96 100644 --- a/duetector/monitors/sh_monitor.py +++ b/duetector/monitors/sh_monitor.py @@ -2,6 +2,11 @@ from datetime import datetime from typing import Any, Callable, Dict, List, NamedTuple, Optional +try: + from functools import cache +except ImportError: + from functools import lru_cache as cache + from duetector.collectors.base import Collector from duetector.log import logger from duetector.managers.collector import CollectorManager @@ -27,10 +32,11 @@ def __init__(self, backend, timeout=5): def attach(self, tracer): self.tracers[tracer] = tracer.comm - def delete(self, tracer): + def detach(self, tracer): if tracer in self.tracers: self.tracers.pop(tracer) + @cache def get_poller(self, tracer) -> Callable[[None], None]: """ Provide a callback function for ``Poller``.