diff --git a/app/src/protocol_ifc.py b/app/src/protocol_ifc.py new file mode 100644 index 0000000..90ee8f1 --- /dev/null +++ b/app/src/protocol_ifc.py @@ -0,0 +1,43 @@ +from abc import abstractmethod +import weakref + +if __name__ == "app.src.protocol_ifc": + from app.src.iter_registry import AbstractIterMeta + from app.src.async_ifc import AsyncIfc +else: # pragma: no cover + from iter_registry import AbstractIterMeta + from async_ifc import AsyncIfc + + +class ProtocolIfc(metaclass=AbstractIterMeta): + + @abstractmethod + def __init__(self, addr, ifc: "AsyncIfc", server_side: bool, + client_mode: bool = False, id_str=b''): + pass # pragma: no cover + + @abstractmethod + def close(self): + pass # pragma: no cover + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc, tb): + self.close() + + +class Test(): + def test_method(self): + return self + + +class ProtocolIfcImpl(ProtocolIfc, Test): + _registry = [] + + def __init__(self, addr, ifc: "AsyncIfc", server_side: bool, + client_mode: bool = False, id_str=b''): + self._registry.append(weakref.ref(self)) + + def close(self): + pass # pragma: no cover