Initial commit

This commit is contained in:
kdusek
2025-12-09 12:13:01 +01:00
commit 8e654ed209
13332 changed files with 2695056 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import types
import typing as tp
from threading import Lock as T_LOCK
import anyio
class AsyncLock:
def __init__(self) -> None:
self._lock = anyio.Lock()
async def __aenter__(self) -> None:
await self._lock.acquire()
async def __aexit__(
self,
exc_type: tp.Optional[tp.Type[BaseException]] = None,
exc_value: tp.Optional[BaseException] = None,
traceback: tp.Optional[types.TracebackType] = None,
) -> None:
self._lock.release()
class Lock:
def __init__(self) -> None:
self._lock = T_LOCK()
def __enter__(self) -> None:
self._lock.acquire()
def __exit__(
self,
exc_type: tp.Optional[tp.Type[BaseException]] = None,
exc_value: tp.Optional[BaseException] = None,
traceback: tp.Optional[types.TracebackType] = None,
) -> None:
self._lock.release()