@@ -133,17 +133,17 @@ def _default_ident(self):
133133
134134 # track associations with current request
135135 _allow_stdin = Bool (False )
136- _parent_headers = Dict ({"shell" : {}, "control" : {}})
136+ _parents = Dict ({"shell" : {}, "control" : {}})
137137 _parent_ident = Dict ({'shell' : b'' , 'control' : b'' })
138138
139139 @property
140140 def _parent_header (self ):
141141 warnings .warn (
142- "Kernel._parent_header is deprecated in ipykernel 6. Use .get_parent_header ()" ,
142+ "Kernel._parent_header is deprecated in ipykernel 6. Use .get_parent ()" ,
143143 DeprecationWarning ,
144144 stacklevel = 2 ,
145145 )
146- return self .get_parent_header (channel = "shell" )
146+ return self .get_parent (channel = "shell" )
147147
148148 # Time to sleep after flushing the stdout/err buffers in each execute
149149 # cycle. While this introduces a hard limit on the minimal latency of the
@@ -218,23 +218,6 @@ def __init__(self, **kwargs):
218218
219219 self .control_queue = Queue ()
220220
221- def get_parent_header (self , channel = "shell" ):
222- """Get the parent header associated with a channel.
223-
224- .. versionadded:: 6
225-
226- Parameters
227- ----------
228- channel : str
229- the name of the channel ('shell' or 'control')
230-
231- Returns
232- -------
233- header : dict
234- the parent header for the most recent request on the channel.
235- """
236- return self ._parent_headers .get (channel , {})
237-
238221 def dispatch_control (self , msg ):
239222 self .control_queue .put_nowait (msg )
240223
@@ -546,7 +529,7 @@ def _publish_status(self, status, channel, parent=None):
546529 self .iopub_socket ,
547530 "status" ,
548531 {"execution_state" : status },
549- parent = parent or self .get_parent_header (channel ),
532+ parent = parent or self .get_parent (channel ),
550533 ident = self ._topic ("status" ),
551534 )
552535
@@ -555,12 +538,12 @@ def _publish_debug_event(self, event):
555538 self .iopub_socket ,
556539 "debug_event" ,
557540 event ,
558- parent = self .get_parent_header ("control" ),
541+ parent = self .get_parent ("control" ),
559542 ident = self ._topic ("debug_event" ),
560543 )
561544
562545 def set_parent (self , ident , parent , channel = 'shell' ):
563- """Set the current parent_header
546+ """Set the current parent request
564547
565548 Side effects (IOPub messages) and replies are associated with
566549 the request that caused them via the parent_header.
@@ -569,7 +552,24 @@ def set_parent(self, ident, parent, channel='shell'):
569552 on the stdin channel.
570553 """
571554 self ._parent_ident [channel ] = ident
572- self ._parent_headers [channel ] = parent
555+ self ._parents [channel ] = parent
556+
557+ def get_parent (self , channel = "shell" ):
558+ """Get the parent request associated with a channel.
559+
560+ .. versionadded:: 6
561+
562+ Parameters
563+ ----------
564+ channel : str
565+ the name of the channel ('shell' or 'control')
566+
567+ Returns
568+ -------
569+ message : dict
570+ the parent message for the most recent request on the channel.
571+ """
572+ return self ._parents .get (channel , {})
573573
574574 def send_response (self , stream , msg_or_type , content = None , ident = None ,
575575 buffers = None , track = False , header = None , metadata = None , channel = 'shell' ):
@@ -585,7 +585,7 @@ def send_response(self, stream, msg_or_type, content=None, ident=None,
585585 stream ,
586586 msg_or_type ,
587587 content ,
588- self .get_parent_header (channel ),
588+ self .get_parent (channel ),
589589 ident ,
590590 buffers ,
591591 track ,
@@ -957,7 +957,7 @@ def getpass(self, prompt='', stream=None):
957957 return self ._input_request (
958958 prompt ,
959959 self ._parent_ident ["shell" ],
960- self .get_parent_header ("shell" ),
960+ self .get_parent ("shell" ),
961961 password = True ,
962962 )
963963
@@ -975,7 +975,7 @@ def raw_input(self, prompt=''):
975975 return self ._input_request (
976976 str (prompt ),
977977 self ._parent_ident ["shell" ],
978- self .get_parent_header ("shell" ),
978+ self .get_parent ("shell" ),
979979 password = False ,
980980 )
981981
0 commit comments