mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-03 22:19:27 +00:00
fix: handle unhashable partial handlers in param count cache
This commit is contained in:
@@ -11,11 +11,22 @@ from crewai.events.types.event_bus_types import AsyncHandler, SyncHandler
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=256)
|
||||
def _get_param_count(handler: Any) -> int:
|
||||
"""Return the number of parameters a handler accepts, with caching."""
|
||||
def _get_param_count_cached(handler: Any) -> int:
|
||||
return len(inspect.signature(handler).parameters)
|
||||
|
||||
|
||||
def _get_param_count(handler: Any) -> int:
|
||||
"""Return the number of parameters a handler accepts, with caching.
|
||||
|
||||
Falls back to uncached introspection for unhashable handlers
|
||||
like functools.partial.
|
||||
"""
|
||||
try:
|
||||
return _get_param_count_cached(handler)
|
||||
except TypeError:
|
||||
return len(inspect.signature(handler).parameters)
|
||||
|
||||
|
||||
def is_async_handler(
|
||||
handler: Any,
|
||||
) -> TypeIs[AsyncHandler]:
|
||||
|
||||
Reference in New Issue
Block a user