File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88from functools import partial
99import itertools
1010import logging
11+ import inspect
1112from signal import signal , default_int_handler , SIGINT
1213import sys
1314import time
@@ -237,7 +238,9 @@ async def process_control(self, msg):
237238 self .log .error ("UNKNOWN CONTROL MESSAGE TYPE: %r" , msg_type )
238239 else :
239240 try :
240- await handler (self .control_stream , idents , msg )
241+ result = handler (self .control_stream , idents , msg )
242+ if inspect .isawaitable (result ):
243+ await result
241244 except Exception :
242245 self .log .error ("Exception in control handler:" , exc_info = True )
243246
@@ -303,7 +306,14 @@ async def dispatch_shell(self, msg):
303306 except Exception :
304307 self .log .debug ("Unable to signal in pre_handler_hook:" , exc_info = True )
305308 try :
306- await handler (self .shell_stream , idents , msg )
309+ result = handler (self .shell_stream , idents , msg )
310+ if inspect .isawaitable (result ):
311+ await result
312+ else :
313+ warnings .warn (
314+ "Message handlers should be awaitable" ,
315+ DeprecationWarning ,
316+ stacklevel = 2 )
307317 except Exception :
308318 self .log .error ("Exception in message handler:" , exc_info = True )
309319 finally :
You can’t perform that action at this time.
0 commit comments