1010
1111from IPython .core import release
1212from IPython .utils .tokenutil import token_at_cursor , line_at_cursor
13- from tornado import gen
1413from traitlets import Instance , Type , Any , List , Bool , observe , observe_compat
1514from zmq .eventloop .zmqstream import ZMQStream
1615
@@ -149,8 +148,7 @@ def __init__(self, **kwargs):
149148 'file_extension' : '.py'
150149 }
151150
152- @gen .coroutine
153- def dispatch_debugpy (self , msg ):
151+ async def dispatch_debugpy (self , msg ):
154152 # The first frame is the socket id, we can drop it
155153 frame = msg [1 ].bytes .decode ('utf-8' )
156154 self .log .debug ("Debugpy received: %s" , frame )
@@ -279,9 +277,8 @@ def set_sigint_result():
279277 # restore the previous sigint handler
280278 signal .signal (signal .SIGINT , save_sigint )
281279
282- @gen .coroutine
283- def do_execute (self , code , silent , store_history = True ,
284- user_expressions = None , allow_stdin = False ):
280+ async def do_execute (self , code , silent , store_history = True ,
281+ user_expressions = None , allow_stdin = False ):
285282 shell = self .shell # we'll need this a lot here
286283
287284 self ._forward_input (allow_stdin )
@@ -294,8 +291,7 @@ def do_execute(self, code, silent, store_history=True,
294291 should_run_async = lambda cell : False
295292 # older IPython,
296293 # use blocking run_cell and wrap it in coroutine
297- @gen .coroutine
298- def run_cell (* args , ** kwargs ):
294+ async def run_cell (* args , ** kwargs ):
299295 return shell .run_cell (* args , ** kwargs )
300296 try :
301297
@@ -327,7 +323,7 @@ def run_cell(*args, **kwargs):
327323 with self ._cancel_on_sigint (coro_future ):
328324 res = None
329325 try :
330- res = yield coro_future
326+ res = await coro_future
331327 finally :
332328 shell .events .trigger ('post_execute' )
333329 if not silent :
@@ -407,9 +403,8 @@ def do_complete(self, code, cursor_pos):
407403 'metadata' : {},
408404 'status' : 'ok' }
409405
410- @gen .coroutine
411- def do_debug_request (self , msg ):
412- return (yield self .debugger .process_request (msg ))
406+ async def do_debug_request (self , msg ):
407+ return await self .debugger .process_request (msg )
413408
414409 def _experimental_do_complete (self , code , cursor_pos ):
415410 """
@@ -445,8 +440,6 @@ def _experimental_do_complete(self, code, cursor_pos):
445440 'metadata' : {_EXPERIMENTAL_KEY_NAME : comps },
446441 'status' : 'ok' }
447442
448-
449-
450443 def do_inspect (self , code , cursor_pos , detail_level = 0 ):
451444 name = token_at_cursor (code , cursor_pos )
452445
0 commit comments