Skip to content

Commit

Permalink
[Python] Add documentation to the new context managers
Browse files Browse the repository at this point in the history
  • Loading branch information
agners committed Jun 19, 2024
1 parent 61d0b1b commit 864519d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ def wrapper(*args, **kwargs):


class CallbackContext:
"""A context manager for handling callbacks that are expected to be called exactly once.
The context manager makes sure that no concurrent operations which use the same callback
handlers are executed.
"""

def __init__(self, lock: asyncio.Lock) -> None:
self._lock = lock
self._future = None
Expand All @@ -248,6 +254,11 @@ async def __aexit__(self, exc_type, exc_value, traceback):


class CommissioningContext(CallbackContext):
"""A context manager for handling commissioning callbacks that are expected to be called exactly once.
This context also resets commissioning related device controller state.
"""

def __init__(self, devCtrl: ChipDeviceController, lock: asyncio.Lock) -> None:
super().__init__(lock)
self._devCtrl = devCtrl
Expand Down

0 comments on commit 864519d

Please sign in to comment.