managerabc.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """Abstract base class for kernel managers."""
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. import abc
  5. from typing import Any
  6. class KernelManagerABC(metaclass=abc.ABCMeta):
  7. """KernelManager ABC.
  8. The docstrings for this class can be found in the base implementation:
  9. `jupyter_client.manager.KernelManager`
  10. """
  11. @abc.abstractproperty
  12. def kernel(self) -> Any:
  13. pass
  14. # --------------------------------------------------------------------------
  15. # Kernel management
  16. # --------------------------------------------------------------------------
  17. @abc.abstractmethod
  18. def start_kernel(self, **kw: Any) -> None:
  19. """Start the kernel."""
  20. pass
  21. @abc.abstractmethod
  22. def shutdown_kernel(self, now: bool = False, restart: bool = False) -> None:
  23. """Shut down the kernel."""
  24. pass
  25. @abc.abstractmethod
  26. def restart_kernel(self, now: bool = False, **kw: Any) -> None:
  27. """Restart the kernel."""
  28. pass
  29. @abc.abstractproperty
  30. def has_kernel(self) -> bool:
  31. pass
  32. @abc.abstractmethod
  33. def interrupt_kernel(self) -> None:
  34. """Interrupt the kernel."""
  35. pass
  36. @abc.abstractmethod
  37. def signal_kernel(self, signum: int) -> None:
  38. """Send a signal to the kernel."""
  39. pass
  40. @abc.abstractmethod
  41. def is_alive(self) -> bool:
  42. """Test whether the kernel is alive."""
  43. pass