conkernelclient 0.0.9__tar.gz → 0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: conkernelclient
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: Concurrent-safe Jupyter KernelClient
5
5
  Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
6
6
  License: Apache-2.0
@@ -0,0 +1,2 @@
1
+ __version__ = "0.0.10"
2
+ from .core import *
@@ -21,4 +21,5 @@ d = { 'settings': { 'branch': 'main',
21
21
  'conkernelclient.core.ConKernelClient.stop_channels': ( 'core.html#conkernelclient.stop_channels',
22
22
  'conkernelclient/core.py'),
23
23
  'conkernelclient.core.ConKernelManager': ('core.html#conkernelmanager', 'conkernelclient/core.py'),
24
+ 'conkernelclient.core.DeadKernelError': ('core.html#deadkernelerror', 'conkernelclient/core.py'),
24
25
  'conkernelclient.core._send': ('core.html#_send', 'conkernelclient/core.py')}}}
@@ -3,7 +3,7 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
4
4
 
5
5
  # %% auto #0
6
- __all__ = ['ConKernelClient', 'ConKernelManager']
6
+ __all__ = ['DeadKernelError', 'ConKernelClient', 'ConKernelManager']
7
7
 
8
8
  # %% ../nbs/00_core.ipynb #d3b521c0
9
9
  from queue import Empty
@@ -20,6 +20,9 @@ import asyncio, zmq.asyncio, time, logging
20
20
  # %% ../nbs/00_core.ipynb #737a0fc1
21
21
  _log = logging.getLogger(__name__)
22
22
 
23
+ # %% ../nbs/00_core.ipynb #a093006c
24
+ class DeadKernelError(Exception): pass
25
+
23
26
  # %% ../nbs/00_core.ipynb #374b75d0
24
27
  if not hasattr(Session, '_orig_send'): Session._orig_send = Session.send
25
28
 
@@ -61,6 +64,7 @@ class ConKernelClient(AsyncKernelClient):
61
64
  while True:
62
65
  try: reply = await self.get_shell_msg(timeout=None)
63
66
  except Exception as e:
67
+ if isinstance(e, (AssertionError, OSError, ZMQError)): e = DeadKernelError(f"Kernel socket closed: {e}")
64
68
  self._fail_pending(e)
65
69
  _log.warning(f"_reader died, pending={list(self._pending)}: {e}")
66
70
  break
@@ -111,13 +115,15 @@ class ConKernelClient(AsyncKernelClient):
111
115
  if subsh_id is not None: msg["header"]["subshell_id"] = subsh_id
112
116
  msg_id = msg["header"]["msg_id"]
113
117
  if reply: self._pending[msg_id] = (asyncio.Queue(maxsize=1), stop_on_error)
114
- self.shell_channel.send(msg)
118
+ try: self.shell_channel.send(msg)
119
+ except (AssertionError, OSError, ZMQError) as e: raise DeadKernelError(f"Kernel socket closed: {e}") from e
115
120
  if not reply: return msg_id
116
121
  return self._async_recv_reply(msg_id, timeout=timeout)
117
122
 
118
123
  async def stdin_send(self, msg:dict):
119
124
  "Send on `stdin_channel` then ping event loop"
120
- self.stdin_channel.send(msg)
125
+ try: self.stdin_channel.send(msg)
126
+ except (AssertionError, OSError, ZMQError) as e: raise DeadKernelError(f"Kernel socket closed: {e}") from e
121
127
  await asyncio.sleep(0.01)
122
128
 
123
129
  # %% ../nbs/00_core.ipynb #b828c222
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: conkernelclient
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: Concurrent-safe Jupyter KernelClient
5
5
  Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
6
6
  License: Apache-2.0
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.9"
2
- from .core import *