11
11
import queue
12
12
import sys
13
13
import threading
14
+ from threading import Thread
14
15
import time
15
16
import typing as t
16
17
import uuid
@@ -95,17 +96,16 @@ class Kernel(SingletonConfigurable):
95
96
implementation_version : str
96
97
banner : str
97
98
98
- _is_test = Bool ( False )
99
+ _is_test : bool
99
100
100
101
control_socket = Instance (zmq .asyncio .Socket , allow_none = True )
101
102
control_tasks : t .Any = List ()
102
103
103
104
debug_shell_socket = Any ()
105
+ control_thread : Thread
106
+ shell_channel_thread : Thread
104
107
105
- control_thread = Any ()
106
- shell_channel_thread = Any ()
107
108
iopub_socket = Any ()
108
- iopub_thread = Any ()
109
109
stdin_socket = Any ()
110
110
log : logging .Logger = Instance (logging .Logger , allow_none = True ) # type:ignore[assignment]
111
111
@@ -217,6 +217,9 @@ def _parent_header(self):
217
217
"shutdown_request" ,
218
218
"is_complete_request" ,
219
219
"interrupt_request" ,
220
+ # I have the impression that there is amix/match debug_request and do_debug_request
221
+ # former was from ipyparallel but is marked as deprecated, but now call do_debug_request
222
+ # "do_debug_request"
220
223
# deprecated:
221
224
"apply_request" ,
222
225
]
@@ -258,6 +261,17 @@ def __init__(self, **kwargs):
258
261
self .do_execute , ["cell_meta" , "cell_id" ]
259
262
)
260
263
264
+ if not inspect .iscoroutinefunction (self .do_debug_request ):
265
+ # warning at init time, as we want to warn early enough, even if the
266
+ # function is not called
267
+ warnings .warn (
268
+ "`do_debug_request` will be required to be a coroutine "
269
+ "functions in the future. coroutine functions have ben supported "
270
+ "since ipykernel 6.0 (2021)" ,
271
+ DeprecationWarning ,
272
+ stacklevel = 2 ,
273
+ )
274
+
261
275
async def process_control (self ):
262
276
try :
263
277
while True :
@@ -1008,12 +1022,29 @@ def do_is_complete(self, code):
1008
1022
1009
1023
async def debug_request (self , socket , ident , parent ):
1010
1024
"""Handle a debug request."""
1025
+ # If this is incorrect, remove `debug_request` from the deprecated message types
1026
+ # at the beginning of this class
1027
+ self .log .warning (
1028
+ "abort_request is deprecated in kernel_base since ipykernel 6.10"
1029
+ " (2022). It is only part of IPython parallel. Did you mean do_debug_request ?" ,
1030
+ DeprecationWarning ,
1031
+ )
1011
1032
if not self .session :
1012
1033
return
1013
1034
content = parent ["content" ]
1014
- reply_content = self .do_debug_request (content )
1015
- if inspect .isawaitable (reply_content ):
1016
- reply_content = await reply_content
1035
+ if not inspect .iscoroutinefunction (self .do_debug_request ):
1036
+ # repeat the warning at run
1037
+ reply_content = self .do_debug_request (content )
1038
+ warnings .warn (
1039
+ "`do_debug_request` will be required to be a coroutine "
1040
+ "functions in the future. coroutine functions have ben supported "
1041
+ "since ipykernel 6.0 (2021)" ,
1042
+ DeprecationWarning ,
1043
+ )
1044
+ if inspect .isawaitable (reply_content ):
1045
+ reply_content = await reply_content
1046
+ else :
1047
+ reply_content = await self .do_debug_request (content )
1017
1048
reply_content = json_clean (reply_content )
1018
1049
reply_msg = self .session .send (socket , "debug_reply" , reply_content , parent , ident )
1019
1050
self .log .debug ("%s" , reply_msg )
@@ -1132,7 +1163,11 @@ async def list_subshell_request(self, socket, ident, parent) -> None:
1132
1163
1133
1164
async def apply_request (self , socket , ident , parent ): # pragma: no cover
1134
1165
"""Handle an apply request."""
1135
- self .log .warning ("apply_request is deprecated in kernel_base, moving to ipyparallel." )
1166
+ self .log .warning (
1167
+ "apply_request is deprecated in kernel_base since"
1168
+ " IPykernel 6.10 (2022) , moving to ipyparallel." ,
1169
+ DeprecationWarning ,
1170
+ )
1136
1171
try :
1137
1172
content = parent ["content" ]
1138
1173
bufs = parent ["buffers" ]
@@ -1175,7 +1210,9 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
1175
1210
async def abort_request (self , socket , ident , parent ): # pragma: no cover
1176
1211
"""abort a specific msg by id"""
1177
1212
self .log .warning (
1178
- "abort_request is deprecated in kernel_base. It is only part of IPython parallel"
1213
+ "abort_request is deprecated in kernel_base since ipykernel 6.10"
1214
+ " (2022). It is only part of IPython parallel" ,
1215
+ DeprecationWarning ,
1179
1216
)
1180
1217
msg_ids = parent ["content" ].get ("msg_ids" , None )
1181
1218
if isinstance (msg_ids , str ):
@@ -1194,7 +1231,9 @@ async def abort_request(self, socket, ident, parent): # pragma: no cover
1194
1231
async def clear_request (self , socket , idents , parent ): # pragma: no cover
1195
1232
"""Clear our namespace."""
1196
1233
self .log .warning (
1197
- "clear_request is deprecated in kernel_base. It is only part of IPython parallel"
1234
+ "clear_request is deprecated in kernel_base since IPykernel 6.10"
1235
+ " (2022). It is only part of IPython parallel" ,
1236
+ DeprecationWarning ,
1198
1237
)
1199
1238
content = self .do_clear ()
1200
1239
if self .session :
0 commit comments