20
20
import uuid
21
21
22
22
from .const import LOGGER_PATH
23
- from .handler import current_task
24
23
25
24
_LOGGER = logging .getLogger (LOGGER_PATH + ".jupyter_kernel" )
26
25
@@ -522,7 +521,7 @@ async def control_listen(self, reader, writer):
522
521
"""Task that listens to control messages."""
523
522
try :
524
523
_LOGGER .debug ("control_listen connected" )
525
- await self .housekeep_q .put (["register" , "control" , current_task ()])
524
+ await self .housekeep_q .put (["register" , "control" , asyncio . current_task ()])
526
525
control_socket = ZmqSocket (reader , writer , "ROUTER" )
527
526
await control_socket .handshake ()
528
527
while 1 :
@@ -535,7 +534,7 @@ async def control_listen(self, reader, writer):
535
534
raise
536
535
except EOFError :
537
536
_LOGGER .debug ("control_listen got eof" )
538
- await self .housekeep_q .put (["unregister" , "control" , current_task ()])
537
+ await self .housekeep_q .put (["unregister" , "control" , asyncio . current_task ()])
539
538
control_socket .close ()
540
539
except Exception as err : # pylint: disable=broad-except
541
540
_LOGGER .error ("control_listen exception %s" , err )
@@ -545,7 +544,7 @@ async def stdin_listen(self, reader, writer):
545
544
"""Task that listens to stdin messages."""
546
545
try :
547
546
_LOGGER .debug ("stdin_listen connected" )
548
- await self .housekeep_q .put (["register" , "stdin" , current_task ()])
547
+ await self .housekeep_q .put (["register" , "stdin" , asyncio . current_task ()])
549
548
stdin_socket = ZmqSocket (reader , writer , "ROUTER" )
550
549
await stdin_socket .handshake ()
551
550
while 1 :
@@ -555,7 +554,7 @@ async def stdin_listen(self, reader, writer):
555
554
raise
556
555
except EOFError :
557
556
_LOGGER .debug ("stdin_listen got eof" )
558
- await self .housekeep_q .put (["unregister" , "stdin" , current_task ()])
557
+ await self .housekeep_q .put (["unregister" , "stdin" , asyncio . current_task ()])
559
558
stdin_socket .close ()
560
559
except Exception : # pylint: disable=broad-except
561
560
_LOGGER .error ("stdin_listen exception %s" , traceback .format_exc (- 1 ))
@@ -565,7 +564,7 @@ async def shell_listen(self, reader, writer):
565
564
"""Task that listens to shell messages."""
566
565
try :
567
566
_LOGGER .debug ("shell_listen connected" )
568
- await self .housekeep_q .put (["register" , "shell" , current_task ()])
567
+ await self .housekeep_q .put (["register" , "shell" , asyncio . current_task ()])
569
568
shell_socket = ZmqSocket (reader , writer , "ROUTER" )
570
569
await shell_socket .handshake ()
571
570
while 1 :
@@ -576,7 +575,7 @@ async def shell_listen(self, reader, writer):
576
575
raise
577
576
except EOFError :
578
577
_LOGGER .debug ("shell_listen got eof" )
579
- await self .housekeep_q .put (["unregister" , "shell" , current_task ()])
578
+ await self .housekeep_q .put (["unregister" , "shell" , asyncio . current_task ()])
580
579
shell_socket .close ()
581
580
except Exception : # pylint: disable=broad-except
582
581
_LOGGER .error ("shell_listen exception %s" , traceback .format_exc (- 1 ))
@@ -586,7 +585,7 @@ async def heartbeat_listen(self, reader, writer):
586
585
"""Task that listens and responds to heart beat messages."""
587
586
try :
588
587
_LOGGER .debug ("heartbeat_listen connected" )
589
- await self .housekeep_q .put (["register" , "heartbeat" , current_task ()])
588
+ await self .housekeep_q .put (["register" , "heartbeat" , asyncio . current_task ()])
590
589
heartbeat_socket = ZmqSocket (reader , writer , "REP" )
591
590
await heartbeat_socket .handshake ()
592
591
while 1 :
@@ -597,7 +596,7 @@ async def heartbeat_listen(self, reader, writer):
597
596
raise
598
597
except EOFError :
599
598
_LOGGER .debug ("heartbeat_listen got eof" )
600
- await self .housekeep_q .put (["unregister" , "heartbeat" , current_task ()])
599
+ await self .housekeep_q .put (["unregister" , "heartbeat" , asyncio . current_task ()])
601
600
heartbeat_socket .close ()
602
601
except Exception : # pylint: disable=broad-except
603
602
_LOGGER .error ("heartbeat_listen exception: %s" , traceback .format_exc (- 1 ))
@@ -607,7 +606,7 @@ async def iopub_listen(self, reader, writer):
607
606
"""Task that listens to iopub messages."""
608
607
try :
609
608
_LOGGER .debug ("iopub_listen connected" )
610
- await self .housekeep_q .put (["register" , "iopub" , current_task ()])
609
+ await self .housekeep_q .put (["register" , "iopub" , asyncio . current_task ()])
611
610
iopub_socket = ZmqSocket (reader , writer , "PUB" )
612
611
await iopub_socket .handshake ()
613
612
self .iopub_socket .add (iopub_socket )
@@ -617,7 +616,7 @@ async def iopub_listen(self, reader, writer):
617
616
except asyncio .CancelledError : # pylint: disable=try-except-raise
618
617
raise
619
618
except EOFError :
620
- await self .housekeep_q .put (["unregister" , "iopub" , current_task ()])
619
+ await self .housekeep_q .put (["unregister" , "iopub" , asyncio . current_task ()])
621
620
iopub_socket .close ()
622
621
self .iopub_socket .discard (iopub_socket )
623
622
_LOGGER .debug ("iopub_listen got eof" )
@@ -669,7 +668,7 @@ async def housekeep_run(self):
669
668
670
669
async def startup_timeout (self ):
671
670
"""Shut down the session if nothing connects after 30 seconds."""
672
- await self .housekeep_q .put (["register" , "startup_timeout" , current_task ()])
671
+ await self .housekeep_q .put (["register" , "startup_timeout" , asyncio . current_task ()])
673
672
await asyncio .sleep (30 )
674
673
if self .task_cnt_max == 1 :
675
674
#
@@ -680,7 +679,7 @@ async def startup_timeout(self):
680
679
self .session_cleanup_callback ()
681
680
self .session_cleanup_callback = None
682
681
await self .housekeep_q .put (["shutdown" ])
683
- await self .housekeep_q .put (["unregister" , "startup_timeout" , current_task ()])
682
+ await self .housekeep_q .put (["unregister" , "startup_timeout" , asyncio . current_task ()])
684
683
685
684
async def start_one_server (self , callback ):
686
685
"""Start a server by finding an available port."""
0 commit comments