mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2026-03-05 20:41:25 +03:00
28 lines
538 B
Python
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:
|
|
...
|