channelsabc.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """Abstract base classes for kernel client channels"""
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. import abc
  5. class ChannelABC(metaclass=abc.ABCMeta):
  6. """A base class for all channel ABCs."""
  7. @abc.abstractmethod
  8. def start(self) -> None:
  9. """Start the channel."""
  10. pass
  11. @abc.abstractmethod
  12. def stop(self) -> None:
  13. """Stop the channel."""
  14. pass
  15. @abc.abstractmethod
  16. def is_alive(self) -> bool:
  17. """Test whether the channel is alive."""
  18. pass
  19. class HBChannelABC(ChannelABC):
  20. """HBChannel ABC.
  21. The docstrings for this class can be found in the base implementation:
  22. `jupyter_client.channels.HBChannel`
  23. """
  24. @abc.abstractproperty
  25. def time_to_dead(self) -> float:
  26. pass
  27. @abc.abstractmethod
  28. def pause(self) -> None:
  29. """Pause the heartbeat channel."""
  30. pass
  31. @abc.abstractmethod
  32. def unpause(self) -> None:
  33. """Unpause the heartbeat channel."""
  34. pass
  35. @abc.abstractmethod
  36. def is_beating(self) -> bool:
  37. """Test whether the channel is beating."""
  38. pass