-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: clean up setters and deprecate older functions (#37)
- Loading branch information
1 parent
4bb1723
commit 28b47e2
Showing
5 changed files
with
97 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import asyncio | ||
from functools import wraps | ||
from typing import Any, Callable, Coroutine, TypeVar | ||
|
||
GLOBAL_BLUETOOTH_LOCK: asyncio.Lock = asyncio.Lock() # type: ignore | ||
|
||
RT = TypeVar("RT") | ||
|
||
|
||
def bluetooth_lock( | ||
func: Callable[..., Coroutine[Any, Any, RT]] | ||
) -> Callable[..., Coroutine[Any, Any, RT]]: | ||
"""Decorator to lock bluetooth operations.""" | ||
|
||
@wraps(func) | ||
async def wrapped(*args, **kwargs) -> RT: | ||
|
||
async with GLOBAL_BLUETOOTH_LOCK: | ||
return await func(*args, **kwargs) | ||
|
||
return wrapped |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters