12
12
import queue
13
13
import sys
14
14
import threading
15
+ from threading import Thread
15
16
import time
16
17
import typing as t
17
18
import uuid
@@ -96,16 +97,17 @@ class Kernel(SingletonConfigurable):
96
97
implementation_version : str
97
98
banner : str
98
99
99
- _is_test = Bool ( False )
100
+ _is_test : bool
100
101
101
102
control_socket = Instance (zmq .asyncio .Socket , allow_none = True )
102
103
control_tasks : t .Any = List ()
103
104
104
105
debug_shell_socket = Any ()
105
106
106
- control_thread = Any ()
107
+ control_thread : Thread
108
+ iopub_thread = Thread
109
+
107
110
iopub_socket = Any ()
108
- iopub_thread = Any ()
109
111
stdin_socket = Any ()
110
112
log : logging .Logger = Instance (logging .Logger , allow_none = True ) # type:ignore[assignment]
111
113
@@ -217,6 +219,9 @@ def _parent_header(self):
217
219
"shutdown_request" ,
218
220
"is_complete_request" ,
219
221
"interrupt_request" ,
222
+ # I have the impression that there is amix/match debug_request and do_debug_request
223
+ # former was from ipyparallel but is marked as deprecated, but now call do_debug_request
224
+ # "do_debug_request"
220
225
# deprecated:
221
226
"apply_request" ,
222
227
]
@@ -253,6 +258,17 @@ def __init__(self, **kwargs):
253
258
self .do_execute , ["cell_meta" , "cell_id" ]
254
259
)
255
260
261
+ if not inspect .iscoroutinefunction (self .do_debug_request ):
262
+ # warning at init time, as we want to warn early enough, even if the
263
+ # function is not called
264
+ warnings .warn (
265
+ "`do_debug_request` will be required to be a coroutine "
266
+ "functions in the future. coroutine functions have ben supported "
267
+ "since ipykernel 6.0 (2021)" ,
268
+ DeprecationWarning ,
269
+ stacklevel = 2 ,
270
+ )
271
+
256
272
async def process_control (self ):
257
273
try :
258
274
while True :
@@ -915,12 +931,29 @@ def do_is_complete(self, code):
915
931
916
932
async def debug_request (self , socket , ident , parent ):
917
933
"""Handle a debug request."""
934
+ # If this is incorrect, remove `debug_request` from the deprecated message types
935
+ # at the beginning of this class
936
+ self .log .warning (
937
+ "abort_request is deprecated in kernel_base since ipykernel 6.10"
938
+ " (2022). It is only part of IPython parallel. Did you mean do_debug_request ?" ,
939
+ DeprecationWarning ,
940
+ )
918
941
if not self .session :
919
942
return
920
943
content = parent ["content" ]
921
- reply_content = self .do_debug_request (content )
922
- if inspect .isawaitable (reply_content ):
923
- reply_content = await reply_content
944
+ if not inspect .iscoroutinefunction (self .do_debug_request ):
945
+ # repeat the warning at run
946
+ reply_content = self .do_debug_request (content )
947
+ warnings .warn (
948
+ "`do_debug_request` will be required to be a coroutine "
949
+ "functions in the future. coroutine functions have ben supported "
950
+ "since ipykernel 6.0 (2021)" ,
951
+ DeprecationWarning ,
952
+ )
953
+ if inspect .isawaitable (reply_content ):
954
+ reply_content = await reply_content
955
+ else :
956
+ reply_content = await self .do_debug_request (content )
924
957
reply_content = json_clean (reply_content )
925
958
reply_msg = self .session .send (socket , "debug_reply" , reply_content , parent , ident )
926
959
self .log .debug ("%s" , reply_msg )
@@ -983,7 +1016,11 @@ async def do_debug_request(self, msg):
983
1016
984
1017
async def apply_request (self , socket , ident , parent ): # pragma: no cover
985
1018
"""Handle an apply request."""
986
- self .log .warning ("apply_request is deprecated in kernel_base, moving to ipyparallel." )
1019
+ self .log .warning (
1020
+ "apply_request is deprecated in kernel_base since"
1021
+ " IPykernel 6.10 (2022) , moving to ipyparallel." ,
1022
+ DeprecationWarning ,
1023
+ )
987
1024
try :
988
1025
content = parent ["content" ]
989
1026
bufs = parent ["buffers" ]
@@ -1024,7 +1061,9 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
1024
1061
async def abort_request (self , socket , ident , parent ): # pragma: no cover
1025
1062
"""abort a specific msg by id"""
1026
1063
self .log .warning (
1027
- "abort_request is deprecated in kernel_base. It is only part of IPython parallel"
1064
+ "abort_request is deprecated in kernel_base since ipykernel 6.10"
1065
+ " (2022). It is only part of IPython parallel" ,
1066
+ DeprecationWarning ,
1028
1067
)
1029
1068
msg_ids = parent ["content" ].get ("msg_ids" , None )
1030
1069
if isinstance (msg_ids , str ):
@@ -1043,7 +1082,9 @@ async def abort_request(self, socket, ident, parent): # pragma: no cover
1043
1082
async def clear_request (self , socket , idents , parent ): # pragma: no cover
1044
1083
"""Clear our namespace."""
1045
1084
self .log .warning (
1046
- "clear_request is deprecated in kernel_base. It is only part of IPython parallel"
1085
+ "clear_request is deprecated in kernel_base since IPykernel 6.10"
1086
+ " (2022). It is only part of IPython parallel" ,
1087
+ DeprecationWarning ,
1047
1088
)
1048
1089
content = self .do_clear ()
1049
1090
if self .session :
0 commit comments