17
17
import warnings
18
18
from datetime import datetime
19
19
from signal import SIGINT , SIGTERM , Signals
20
+ from threading import Thread
20
21
21
22
from .thread import CONTROL_THREAD_NAME
22
23
@@ -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 = False
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 :
@@ -1007,13 +1021,35 @@ def do_is_complete(self, code):
1007
1021
return {"status" : "unknown" }
1008
1022
1009
1023
async def debug_request (self , socket , ident , parent ):
1010
- """Handle a debug request."""
1024
+ """Handle a debug request.
1025
+
1026
+ Seem Deprecated
1027
+ """
1028
+ # If this is incorrect, remove `debug_request` from the deprecated message types
1029
+ # at the beginning of this class
1030
+ warnings .warn (
1031
+ "debug_request is deprecated in kernel_base since ipykernel 6.10"
1032
+ " (2022). It is only part of IPython parallel. Did you mean do_debug_request ?" ,
1033
+ DeprecationWarning ,
1034
+ stacklevel = 2 ,
1035
+ )
1011
1036
if not self .session :
1012
1037
return
1013
1038
content = parent ["content" ]
1014
- reply_content = self .do_debug_request (content )
1015
- if inspect .isawaitable (reply_content ):
1016
- reply_content = await reply_content
1039
+ if not inspect .iscoroutinefunction (self .do_debug_request ):
1040
+ # repeat the warning at run
1041
+ reply_content = self .do_debug_request (content )
1042
+ warnings .warn (
1043
+ "`do_debug_request` will be required to be a coroutine "
1044
+ "functions in the future. coroutine functions have ben supported "
1045
+ "since ipykernel 6.0 (2021)" ,
1046
+ DeprecationWarning ,
1047
+ stacklevel = 1 ,
1048
+ )
1049
+ if inspect .isawaitable (reply_content ):
1050
+ reply_content = await reply_content
1051
+ else :
1052
+ reply_content = await self .do_debug_request (content )
1017
1053
reply_content = json_clean (reply_content )
1018
1054
reply_msg = self .session .send (socket , "debug_reply" , reply_content , parent , ident )
1019
1055
self .log .debug ("%s" , reply_msg )
@@ -1132,7 +1168,12 @@ async def list_subshell_request(self, socket, ident, parent) -> None:
1132
1168
1133
1169
async def apply_request (self , socket , ident , parent ): # pragma: no cover
1134
1170
"""Handle an apply request."""
1135
- self .log .warning ("apply_request is deprecated in kernel_base, moving to ipyparallel." )
1171
+ warnings .warn (
1172
+ "apply_request is deprecated in kernel_base since"
1173
+ " IPykernel 6.10 (2022) , moving to ipyparallel." ,
1174
+ DeprecationWarning ,
1175
+ stacklevel = 2 ,
1176
+ )
1136
1177
try :
1137
1178
content = parent ["content" ]
1138
1179
bufs = parent ["buffers" ]
@@ -1174,8 +1215,11 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
1174
1215
1175
1216
async def abort_request (self , socket , ident , parent ): # pragma: no cover
1176
1217
"""abort a specific msg by id"""
1177
- self .log .warning (
1178
- "abort_request is deprecated in kernel_base. It is only part of IPython parallel"
1218
+ warnings .warn (
1219
+ "abort_request is deprecated in kernel_base since ipykernel 6.10"
1220
+ " (2022). It is only part of IPython parallel" ,
1221
+ DeprecationWarning ,
1222
+ stacklevel = 2 ,
1179
1223
)
1180
1224
msg_ids = parent ["content" ].get ("msg_ids" , None )
1181
1225
if isinstance (msg_ids , str ):
@@ -1193,8 +1237,11 @@ async def abort_request(self, socket, ident, parent): # pragma: no cover
1193
1237
1194
1238
async def clear_request (self , socket , idents , parent ): # pragma: no cover
1195
1239
"""Clear our namespace."""
1196
- self .log .warning (
1197
- "clear_request is deprecated in kernel_base. It is only part of IPython parallel"
1240
+ warnings .warn (
1241
+ "clear_request is deprecated in kernel_base since IPykernel 6.10"
1242
+ " (2022). It is only part of IPython parallel" ,
1243
+ DeprecationWarning ,
1244
+ stacklevel = 2 ,
1198
1245
)
1199
1246
content = self .do_clear ()
1200
1247
if self .session :
0 commit comments