mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-14 15:02:37 +00:00
refactor: use lru_cache for handler param count
This commit is contained in:
@@ -10,17 +10,10 @@ from crewai.events.base_events import BaseEvent
|
||||
from crewai.events.types.event_bus_types import AsyncHandler, SyncHandler
|
||||
|
||||
|
||||
_handler_param_count: dict[int, int] = {}
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=256)
|
||||
def _get_param_count(handler: Any) -> int:
|
||||
"""Return the number of parameters a handler accepts, with caching."""
|
||||
key = id(handler)
|
||||
count = _handler_param_count.get(key)
|
||||
if count is None:
|
||||
count = len(inspect.signature(handler).parameters)
|
||||
_handler_param_count[key] = count
|
||||
return count
|
||||
return len(inspect.signature(handler).parameters)
|
||||
|
||||
|
||||
def is_async_handler(
|
||||
|
||||
Reference in New Issue
Block a user