From dbc7eb9f2e995026bb28fb5426ff0ba65cda5b63 Mon Sep 17 00:00:00 2001 From: Roman Glushko Date: Tue, 7 Nov 2023 14:47:42 +0200 Subject: [PATCH] Implemented the default name for context managers --- hyx/bulkhead/api.py | 4 ++-- hyx/events.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hyx/bulkhead/api.py b/hyx/bulkhead/api.py index 15ef91d..1528a94 100644 --- a/hyx/bulkhead/api.py +++ b/hyx/bulkhead/api.py @@ -4,7 +4,7 @@ from hyx.bulkhead.events import _BULKHEAD_LISTENERS, BulkheadListener from hyx.bulkhead.manager import BulkheadManager -from hyx.events import EventDispatcher, EventManager +from hyx.events import EventDispatcher, EventManager, get_default_name from hyx.typing import FuncT @@ -40,9 +40,9 @@ def __init__( ) self._manager = BulkheadManager( + name=name or get_default_name(), max_concurrency=max_concurrency, max_capacity=max_capacity, - name=name, event_dispatcher=event_dispatcher.as_listener, ) diff --git a/hyx/events.py b/hyx/events.py index 3b8bcda..96900fe 100644 --- a/hyx/events.py +++ b/hyx/events.py @@ -184,6 +184,6 @@ def get_default_name(func: Optional[Callable] = None) -> str: return func.__name__ # this is more for context managers - traceback.extract_stack(limit=3) - # TODO: - return "" + stack = traceback.extract_stack(limit=3) + + return stack[0].name