python-dependency-injector/src/dependency_injector/resources.py
2022-01-16 20:32:42 -05:00

28 lines
538 B
Python

"""Resources module."""
import abc
from typing import TypeVar, Generic, Optional
T = TypeVar("T")
class Resource(Generic[T], metaclass=abc.ABCMeta):
@abc.abstractmethod
def init(self, *args, **kwargs) -> Optional[T]:
...
def shutdown(self, resource: Optional[T]) -> None:
...
class AsyncResource(Generic[T], metaclass=abc.ABCMeta):
@abc.abstractmethod
async def init(self, *args, **kwargs) -> Optional[T]:
...
async def shutdown(self, resource: Optional[T]) -> None:
...