diff --git a/aiowialon/api.py b/aiowialon/api.py index bf8afe8..be0457c 100644 --- a/aiowialon/api.py +++ b/aiowialon/api.py @@ -92,7 +92,18 @@ def timeout(self, timeout: float) -> None: @property def session_lock(self) -> Callable: - """Decorator to set exclusive session access for long critical operations""" + """ + Decorator to set exclusive session access for long critical operations + + >>> # Example + >>> from aiowialon import Wialon + >>> wialon = Wialon() + >>> + >>> @wialon.avl_event_handler() + >>> @wialon.session_lock # exclusive session lock for callback's frame + >>> async def unit_event(event: AvlEvent): + >>> await wialon.core_search_item(id=event.data.i, flags=1) + """ return self.__exclusive_session_lock.lock diff --git a/examples/aiolock.py b/examples/aiolock.py index e0f6396..91ba5bb 100644 --- a/examples/aiolock.py +++ b/examples/aiolock.py @@ -39,7 +39,7 @@ async def register_avl_events(session_login): @wialon.avl_event_handler() @wialon.session_lock # exclusive session lock for callback's frame async def unit_event(event: AvlEvent): - await wialon.core_search_item(id=734455, flags=1) + await wialon.core_search_item(id=event.data.i, flags=1) print("Handler got event:", event) for i in range(5): print("Waiting exclusive operation", i, "item:", event.data.i)