1212import queue
1313import sys
1414import threading
15+ from threading import Thread
1516import time
1617import typing as t
1718import uuid
@@ -96,16 +97,17 @@ class Kernel(SingletonConfigurable):
9697 implementation_version : str
9798 banner : str
9899
99- _is_test = Bool ( False )
100+ _is_test : bool
100101
101102 control_socket = Instance (zmq .asyncio .Socket , allow_none = True )
102103 control_tasks : t .Any = List ()
103104
104105 debug_shell_socket = Any ()
105106
106- control_thread = Any ()
107+ control_thread : Thread
108+ iopub_thread = Thread
109+
107110 iopub_socket = Any ()
108- iopub_thread = Any ()
109111 stdin_socket = Any ()
110112 log : logging .Logger = Instance (logging .Logger , allow_none = True ) # type:ignore[assignment]
111113
@@ -217,6 +219,9 @@ def _parent_header(self):
217219 "shutdown_request" ,
218220 "is_complete_request" ,
219221 "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"
220225 # deprecated:
221226 "apply_request" ,
222227 ]
@@ -253,6 +258,17 @@ def __init__(self, **kwargs):
253258 self .do_execute , ["cell_meta" , "cell_id" ]
254259 )
255260
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+
256272 async def process_control (self ):
257273 try :
258274 while True :
@@ -915,12 +931,29 @@ def do_is_complete(self, code):
915931
916932 async def debug_request (self , socket , ident , parent ):
917933 """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+ )
918941 if not self .session :
919942 return
920943 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 )
924957 reply_content = json_clean (reply_content )
925958 reply_msg = self .session .send (socket , "debug_reply" , reply_content , parent , ident )
926959 self .log .debug ("%s" , reply_msg )
@@ -983,7 +1016,11 @@ async def do_debug_request(self, msg):
9831016
9841017 async def apply_request (self , socket , ident , parent ): # pragma: no cover
9851018 """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+ )
9871024 try :
9881025 content = parent ["content" ]
9891026 bufs = parent ["buffers" ]
@@ -1024,7 +1061,9 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
10241061 async def abort_request (self , socket , ident , parent ): # pragma: no cover
10251062 """abort a specific msg by id"""
10261063 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 ,
10281067 )
10291068 msg_ids = parent ["content" ].get ("msg_ids" , None )
10301069 if isinstance (msg_ids , str ):
@@ -1043,7 +1082,9 @@ async def abort_request(self, socket, ident, parent): # pragma: no cover
10431082 async def clear_request (self , socket , idents , parent ): # pragma: no cover
10441083 """Clear our namespace."""
10451084 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 ,
10471088 )
10481089 content = self .do_clear ()
10491090 if self .session :
0 commit comments