minor refactor

This commit is contained in:
Gokul Mohanarangan
2023-07-10 22:48:22 +05:30
parent 73c4270764
commit 3128813ca3
8 changed files with 82 additions and 85 deletions

View File

@@ -1,9 +1,10 @@
import asyncio
from functools import partial
import contextlib
from functools import partial
from threading import Lock
from typing import ContextManager, Generic, TypeVar
def run_in_executor(func, *args, executor=None, **kwargs):
callback = partial(func, *args, **kwargs)
loop = asyncio.get_event_loop()
@@ -11,6 +12,8 @@ def run_in_executor(func, *args, executor=None, **kwargs):
T = TypeVar("T")
class Mutex(Generic[T]):
def __init__(self, value: T):
self.__value = value
@@ -22,4 +25,4 @@ class Mutex(Generic[T]):
try:
yield self.__value
finally:
self.__lock.release()
self.__lock.release()