clientabc.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. """Abstract base class for kernel clients"""
  2. # -----------------------------------------------------------------------------
  3. # Copyright (c) The Jupyter Development Team
  4. #
  5. # Distributed under the terms of the BSD License. The full license is in
  6. # the file COPYING, distributed as part of this software.
  7. # -----------------------------------------------------------------------------
  8. # -----------------------------------------------------------------------------
  9. # Imports
  10. # -----------------------------------------------------------------------------
  11. from __future__ import annotations
  12. import abc
  13. from typing import TYPE_CHECKING, Any
  14. if TYPE_CHECKING:
  15. from .channelsabc import ChannelABC
  16. # -----------------------------------------------------------------------------
  17. # Main kernel client class
  18. # -----------------------------------------------------------------------------
  19. class KernelClientABC(metaclass=abc.ABCMeta):
  20. """KernelManager ABC.
  21. The docstrings for this class can be found in the base implementation:
  22. `jupyter_client.client.KernelClient`
  23. """
  24. @abc.abstractproperty
  25. def kernel(self) -> Any:
  26. pass
  27. @abc.abstractproperty
  28. def shell_channel_class(self) -> type[ChannelABC]:
  29. pass
  30. @abc.abstractproperty
  31. def iopub_channel_class(self) -> type[ChannelABC]:
  32. pass
  33. @abc.abstractproperty
  34. def hb_channel_class(self) -> type[ChannelABC]:
  35. pass
  36. @abc.abstractproperty
  37. def stdin_channel_class(self) -> type[ChannelABC]:
  38. pass
  39. @abc.abstractproperty
  40. def control_channel_class(self) -> type[ChannelABC]:
  41. pass
  42. # --------------------------------------------------------------------------
  43. # Channel management methods
  44. # --------------------------------------------------------------------------
  45. @abc.abstractmethod
  46. def start_channels(
  47. self,
  48. shell: bool = True,
  49. iopub: bool = True,
  50. stdin: bool = True,
  51. hb: bool = True,
  52. control: bool = True,
  53. ) -> None:
  54. """Start the channels for the client."""
  55. pass
  56. @abc.abstractmethod
  57. def stop_channels(self) -> None:
  58. """Stop the channels for the client."""
  59. pass
  60. @abc.abstractproperty
  61. def channels_running(self) -> bool:
  62. """Get whether the channels are running."""
  63. pass
  64. @abc.abstractproperty
  65. def shell_channel(self) -> ChannelABC:
  66. pass
  67. @abc.abstractproperty
  68. def iopub_channel(self) -> ChannelABC:
  69. pass
  70. @abc.abstractproperty
  71. def stdin_channel(self) -> ChannelABC:
  72. pass
  73. @abc.abstractproperty
  74. def hb_channel(self) -> ChannelABC:
  75. pass
  76. @abc.abstractproperty
  77. def control_channel(self) -> ChannelABC:
  78. pass