
    Mhi                     .   d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZ ddlmZmZ ddlmZ ddlmZmZmZmZmZ ddlZddlmZ dd	lmZ dd
lmZ dZdZ dZ! G d d          Z" G d d          Z# G d de          Z$dS )z.Wrappers for forwarding stdout/stderr over zmq    N)b2a_hex)defaultdictdeque)StringIO
TextIOBase)local)AnyCallableDequeDictOptional)extract_header)IOLoop)	ZMQStream   i  c                       e Zd ZdZddZd Zd Zd Zd Ze	d             Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Ze	d             Zd Zd Zd ZdS )IOPubThreada   An object for sending IOPub messages in a background thread

    Prevents a blocking main thread from delaying output from threads.

    IOPubThread(pub_socket).background_socket is a Socket-API-providing object
    whose IO is always run in a thread.
    Fc                 V   || _         d| _        t          |           | _        t	          j                    | _        || _        t          d          | _	        |r| 
                                 t          j                    | _        t                      | _        i | _        t          j                    | _        d| _        d| _        |                                  t          j        | j        d          | _        d| j        _        d| j        _        d| j        _        d| j        _        dS )a  Create IOPub thread

        Parameters
        ----------
        socket : zmq.PUB Socket
            the socket on which messages will be sent.
        pipe : bool
            Whether this process should listen for IOPub messages
            piped from subprocesses.
        F)make_current
   NIOPub)targetnameT)socket_stoppedBackgroundSocketbackground_socketosgetpid_master_pid
_pipe_flagr   io_loop_setup_pipe_in	threadingr   _localr   _events_event_pipesLock_event_pipe_gc_lock_event_pipe_gc_seconds_event_pipe_gc_task_setup_event_pipeThread_thread_mainthreaddaemonpydev_do_not_traceis_pydev_daemon_threadr   )selfr   pipes      R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ipykernel/iostream.py__init__zIOPubThread.__init__1   s     !1$!7!79;;5111 	"!!!o''27''9;3<>3C3C -/#@D    &d.?gNNN!)-&-1*"    c                 J     fd} j                             |            j        s j                                           j        @ fd} j        s j                             |           n j                                          j                             d           dS )z.The inner loop that's actually run in a threadc                  ^    t          j                                                    _        d S N)asyncioensure_future_run_event_pipe_gcr+   r3   s   r5   _start_event_gcz1IOPubThread._thread_main.<locals>._start_event_gcT   s(    '.'<T=T=T=V=V'W'WD$$$r7   Nc                  >   K    j                                          d S r:   )r+   cancelr>   s   r5   _cancelz)IOPubThread._thread_main.<locals>._cancel`   s"      (//11111r7   T)all_fds)r"   run_syncr   startr+   rA   close)r3   r?   rB   s   `  r5   r.   zIOPubThread._thread_mainQ   s    	X 	X 	X 	X 	X 	o...} 	! L   #/2 2 2 2 2 = 2%%g....(//1114(((((r7   c                    | j         j        }|                     t          j                  }d|_        t          t          j        d                                        d          }d|z  x}| _	        |
                    |           t          || j                  | _        | j                            | j                   dS )zLCreate the PULL socket listening for events that should fire in this thread.r      asciizinproc://%sN)r   contextzmqPULLlingerr   r   urandomdecode_event_interfacebindr   r"   _event_pulleron_recv_handle_event)r3   ctxpipe_in_uuidifaces        r5   r,   zIOPubThread._setup_event_pipej   s    k!**SX&&
2''..w77(5(==%U&w==""4#566666r7   c                    K   	 t          j        | j                   d{V  	 |                                  d{V  n5# t          $ r(}t          d| t          j                   Y d}~nd}~ww xY wq)z&Task to run event pipe gc continuouslyTNz)Exception in IOPubThread._event_pipe_gc: file)r;   sleepr*   _event_pipe_gc	Exceptionprintsys
__stderr__)r3   es     r5   r=   zIOPubThread._run_event_pipe_gcv   s      	\- ;<<<<<<<<<\))++++++++++ \ \ \E!EECN[[[[[[[[[\		\s   ? 
A1	A,,A1c                   K   | j         sdS | j        5  t          | j                                                   D ]5\  }}|                                s|                                 | j         |= 6	 ddd           dS # 1 swxY w Y   dS )z.run a single garbage collection on event pipesN)r'   r)   listitemsis_aliverF   )r3   r/   r   s      r5   r]   zIOPubThread._event_pipe_gc   s        	F% 	2 	2"&t'8'>'>'@'@"A"A 2 2(( 2LLNNN)&12	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   AA>>BBc                 f   	 | j         j        }n# t          $ r | j        j        }|                    t
          j                  }d|_        |                    | j	                   || j         _        | j
        5  || j        t          j                    <   ddd           n# 1 swxY w Y   Y nw xY w|S )zSthread-local event pipe for signaling events that should be processed in the threadr   N)r%   
event_pipeAttributeErrorr   rJ   rK   PUSHrM   connectrP   r)   r'   r$   current_thread)r3   rh   rU   s      r5   _event_pipezIOPubThread._event_pipe   s
   	K/JJ 	K 	K 	K+%CCH--J !Jt4555%/DK" ) K K@J!)":"<"<=K K K K K K K K K K K K K K K	K s4    A)B.8B B. B$	$B.'B$	(B.-B.c                     t          | j                  }t          |          D ]%}| j                                        } |             &dS )zHandle an event on the event pipe

        Content of the message is ignored.

        Whenever *an* event arrives on the event stream,
        *all* waiting events are processed in order.
        N)lenr&   rangepopleft)r3   msgn_events_event_fs        r5   rT   zIOPubThread._handle_event   sR     t|$$x 	 	Al**,,GGIIII	 	r7   c                    | j         j        }t          j        d          | _        |                     t
          j                  }d|_        	 |                    d          | _	        nT# t
          j
        $ rB}t          j        d|z  dz   d           d| _        |                                 Y d	}~d	S d	}~ww xY wt          || j                  | _        | j                            | j                   d	S )
z7setup listening pipe for IOPub from forked subprocessesrH   r   ztcp://127.0.0.1z)Couldn't bind IOPub Pipe to 127.0.0.1: %sz'
subprocess output will be unavailable.   
stacklevelFN)r   rJ   r   rN   
_pipe_uuidrK   rL   rM   bind_to_random_port
_pipe_portZMQErrorwarningswarnr!   rF   r   r"   _pipe_inrS   _handle_pipe_msg)r3   rU   rV   rb   s       r5   r#   zIOPubThread._setup_pipe_in   s    k! *R..**SX&&
	%99:KLLDOO| 	 	 	M;a?<=   
 $DOMMOOOFFFFF	 "'4<88d344444s   A( (B977B44B9c                     | j         r|                                 sdS |d         | j        k    rt          d|t          j                   dS |                     |dd                    dS )z'handle a pipe message from a subprocessNr   zBad pipe message: %srZ   r   )r!   _is_master_processrz   r_   r`   ra   send_multipartr3   rr   s     r5   r   zIOPubThread._handle_pipe_msg   st     	d&=&=&?&? 	Fq6T_$$(#CNCCCCFCG$$$$$r7   c                     t          j                    }|                    t           j                  }d|_        |                    d| j        z             ||fS )Ni  ztcp://127.0.0.1:%i)rK   Contextr   rj   rM   rk   r|   )r3   rU   pipe_outs      r5   _setup_pipe_outzIOPubThread._setup_pipe_out   sM    kmm::ch''-?@@@H}r7   c                 :    t          j                    | j        k    S r:   r   r   r    r>   s    r5   r   zIOPubThread._is_master_process       y{{d...r7   c                 T    | j         r|                                 rt          S t          S )z8check for forks, and switch to zmq pipeline if necessary)r!   r   MASTERCHILDr>   s    r5   _check_mp_modezIOPubThread._check_mp_mode   s)     	$"9"9";"; 	Mr7   c                     d| j         _        | j                                          t          j        | j                   dS )zStart the IOPub threadr   N)r/   r   rE   atexitregisterstopr>   s    r5   rE   zIOPubThread.start   s:    " 		"""""r7   c                    d| _         | j                                        sdS | j                            | j        j                   | j                            d           | j                                        rd}t          |          | j        	                                D ]\  }}|
                                 dS )zStop the IOPub threadTN   )timeoutz,IOPub thread did not terminate in 30 seconds)r   r/   rf   r"   add_callbackr   joinTimeoutErrorr'   re   rF   )r3   rr   _threadrh   s       r5   r   zIOPubThread.stop   s    {##%% 	F!!$,"3444$$$;!! 	$@Cs### $(#4#:#:#<#< 	 	GZ	 	r7   c                 X    | j         rdS | j                                         d| _        dS )zClose the IOPub thread.N)closedr   rF   r>   s    r5   rF   zIOPubThread.close   s0    ; 	Fr7   c                     | j         d u S r:   )r   r>   s    r5   r   zIOPubThread.closed   s    {d""r7   c                     | j                                         r6| j                            |           | j                            d           dS  |             dS )ztSchedule a function to be called in our IO thread.

        If the thread is not running, call immediately.
        r7   N)r/   rf   r&   appendrm   send)r3   fs     r5   schedulezIOPubThread.schedule  s\    
 ;!! 	L"""!!#&&&&&ACCCCCr7   c                 @                            fd           dS )zsend_multipart schedules actual zmq send in my thread.

        If my thread isn't running (e.g. forked process), send immediately.
        c                       j          i S r:   )_really_send)argskwargsr3   s   r5   <lambda>z,IOPubThread.send_multipart.<locals>.<lambda>  s    /d/@@@ r7   N)r   r3   r   r   s   ```r5   r   zIOPubThread.send_multipart  s/    
 	@@@@@@AAAAAr7   c                 6   | j         rdS |                                 }|t          k    r | j        j        |g|R i | dS |                                 \  }} |j        | j        g|g|R i | |                                 |                                 dS )z)The callback that actually sends messagesN)	r   r   r   r   r   r   rz   rF   term)r3   rr   r   r   mp_moderU   r   s          r5   r   zIOPubThread._really_send  s    ; 	F%%''e&DK&s<T<<<V<<<<<
 !0022MC#H#T_$;s$;MdMMMfMMMNNHHJJJJJr7   N)F)__name__
__module____qualname____doc__r6   r.   r,   r=   r]   propertyrm   rT   r#   r   r   r   r   rE   r   rF   r   r   r   r    r7   r5   r   r   (   s_        # # # #@) ) )2
7 
7 
7\ \ \	2 	2 	2   X$  5 5 50% % %  / / /  # # #  $   # # X#
 
 
B B B    r7   r   c                   B     e Zd ZdZdZd Z fdZ fdZd Zd Z	 xZ
S )r   z>Wrapper around IOPub thread that provides zmq send[_multipart]Nc                     || _         dS )zInitialize the socket.N)	io_thread)r3   r   s     r5   r6   zBackgroundSocket.__init__/  s    "r7   c                    |                     d          r6|                    d          r!t                                          |           | j        J t          | j        j        |          r<t          j        d| d| t          d           t          | j        j        |          S t                                          |          S )z2Wrap socket attr access for backward-compatibility__NzAccessing zmq Socket attribute O on BackgroundSocket is deprecated since ipykernel 4.3.0 use .io_thread.socket.rw   rx   )
startswithendswithsuper__getattr__r   hasattrr   r~   r   DeprecationWarninggetattr)r3   attr	__class__s     r5   r   zBackgroundSocket.__getattr__3  s    ??4   	&T]]4%8%8 	&GG%%%~)))4>($// 	8M1$ 1 1*.1 1 #    4>0$777ww""4(((r7   c                 <   |dk    s*|                     d          r9|                    d          r$t                                          ||           dS t	          j        d| d| t          d           | j        J t          | j        j	        ||           dS )zSet an attribute on the socket.r   r   zSetting zmq Socket attribute r   rw   rx   N)
r   r   r   __setattr__r~   r   r   r   setattrr   )r3   r   valuer   s      r5   r   zBackgroundSocket.__setattr__D  s    ;4??4#8#8T]]4=P=PGGe,,,,,M1 1 1*.1 1 #    >---DN)477777r7   c                 &     | j         |gg|R i |S )zSend a message to the socket.)r   )r3   rr   r   r   s       r5   r   zBackgroundSocket.sendS  s'    "t"C5:4:::6:::r7   c                 8    | j         J  | j         j        |i |S )zSchedule send in IO thread)r   r   r   s      r5   r   zBackgroundSocket.send_multipartW  s*    ~))),t~,d=f===r7   )r   r   r   r   r   r6   r   r   r   r   __classcell__)r   s   @r5   r   r   *  s        HHI# # #) ) ) ) )"8 8 8 8 8; ; ;> > > > > > >r7   r   c                   0   e Zd ZU dZdZdZdZdZdZe	e
         ed<   d Zd Z	 	 d"d	d
ddZed             Zej        d             Zd Zd Zd Zd Zd Zed             Zd Zd Zd Zdede	e         fdZd Zd Zd Z d Z!ed             Z"d  Z#d! Z$dS )#	OutStreamzpA file like object that publishes the stream to a 0MQ PUB socket.

    Output is handed off to an IO Thread
    r   g?NzUTF-8_excc                 ^    t          | dd          | j        S d}t          j        |          )z^
        Things like subprocess will peak and write to the fileno() of stderr/stdout.
        _original_stdstream_copyNfileno)r   r   ioUnsupportedOperationr   s     r5   r   zOutStream.filenol  s6     43T::F00%c***r7   c                    	 t          j        | j        t                    }|rt| j        rq|                     |                    d                     t          j        | j        |           t          j        | j        t                    }|r| j        kdS dS dS dS # t          $ r t          j
                    | _        Y dS w xY w)aj  
        We've redirected standards streams 0 and 1 into a pipe.

        We need to watch in a thread and redirect them to the right places.

        1) the ZMQ channels to show in notebook interfaces,
        2) the original stdout/err, to capture errors in terminals.

        We cannot schedule this on the ioloop thread, as this might be blocking.

        replace)errorsN)r   read_fidPIPE_BUFFER_SIZE_should_watchwriterO   r   r^   r`   exc_infor   )r3   btss     r5   _watch_pipe_fdzOutStream._watch_pipe_fdu  s    	''$)%566C ;$, ;

3::Y:778886<<<gdi)9::  ;$, ; ; ; ; ; ; ; ; ;  	' 	' 	'DIIII	's   BB "CCTF)watchfdisattyc                :   |t          j        dt          d           || _        t	          |t
                    sBt          j        d|z  t          d           t          |          }|                                 || _        || _        d|	                                z   | _
        t          j        d          | _        | j                            i            i | _        i | _        i | _        t%          j                    | _        d| _        d| _        |j        | _        t3          j                    | _        t9          t:                    | _        d| _        tA          |          | _!        d| _"        tG                      | _$        |rLtJ          j&        '                    d	          stJ          j&        '                    d
          rdt$          j(        vs|dk    rd| _"        | )                    |           |rtU          |d          rtU          |d          rq| j"        ra	 |+                                }n# tX          $ r d}Y nw xY w|7|| j-        k    r,t]          j/        t]          j0        | j1        d                    }|| _        dS d}	te          |	          dS )a  
        Parameters
        ----------
        session : object
            the session object
        pub_thread : threading.Thread
            the publication thread
        name : str {'stderr', 'stdout'}
            the name of the standard stream to replace
        pipe : object
            the pipe object
        echo : bool
            whether to echo output
        watchfd : bool (default, True)
            Watch the file descriptor corresponding to the replaced stream.
            This is useful if you know some underlying code will write directly
            the file descriptor by its number. It will spawn a watching thread,
            that will swap the give file descriptor for a pipe, read from the
            pipe, and insert this into the current Stream.
        isatty : bool (default, False)
            Indication of whether this stream has terminal capabilities (e.g. can handle colors)

        NzKpipe argument to OutStream is deprecated and ignored since ipykernel 4.2.3.rw   rx   zISince IPykernel 4.3, OutStream should be created with IOPubThread, not %rs   stream.parent_headerFlinuxdarwinPYTEST_CURRENT_TESTforceTr   r   wz(echo argument must be a file-like object)3r~   r   r   session
isinstancer   rE   
pub_threadr   encodetopiccontextvars
ContextVar_parent_headerset_thread_to_parent_thread_to_parent_header_parent_header_globalr   r   r    _flush_pending_subprocess_flush_pendingr"   _io_loopr$   RLock_buffer_lockr   r   _buffersechobool_isattyr   r   r%   r`   platformr   environ_setup_stream_redirectsr   r   r^   _original_stdstream_fdr   TextIOWrapperFileIOr   
ValueError)
r3   r   r   r   r4   r   r   r   echo_fdrr   s
             r5   r6   zOutStream.__init__  s   D M]"    *k22 		M&(23"	    %Z00J$	$++--/
FQF\G
 G
 	###!#(*%%'"9;;#).&"*%O--#H--	F||"gg 	/ ((11	/ 69\5L5LX5V5V	/
 +"*<< '!!!%D((... 	&tV$$ &w)?)? & % '"&++--$ ' ' '"&' *w$:U/U/U  "/I $ = #     !			@ oo%-	& 	&s   !H6 6IIc                    	 | j                                         S # t          $ ra 	 t          j                    j        }|| j        v r| j        |         }|| j        v | j        |         cY S # t          $ r | j	        cY cY S w xY ww xY wr:   )
r   getLookupErrorr$   rl   identr   r   KeyErrorr   )r3   identitys     r5   r   zOutStream.parent_header  s    	2&**,,, 	2 	2 	22$355; $"888#5h?H $"888 4X>>>> 2 2 21111112	2s-    
BAA,)B,B=BBBc                 D    || _         | j                            |          S r:   )r   r   r   )r3   r   s     r5   r   zOutStream.parent_header  s!    %*""&&u---r7   c                     | j         S )zpReturn a bool indicating whether this is an 'interactive' stream.

        Returns:
            Boolean
        )r   r>   s    r5   r   zOutStream.isatty  s     |r7   c                    t          j                    \  }}t          t          |                                          x}| _        t          j        |          | _        t          j        ||           || _	        d | _
        t          j        | j                  | _        d| j        _        | j                                         d S )N)r   T)r   r4   r   r`   r   r   dupr   dup2r   r   r$   r-   r   watch_fd_threadr0   rE   )r3   r   prpwfnos        r5   r   z!OutStream._setup_stream_redirects  s    B,3C,>,>,E,E,G,GGd)(*s%
C		(/t7JKKK&*#""$$$$$r7   c                 :    t          j                    | j        k    S r:   r   r>   s    r5   r   zOutStream._is_master_process&  r   r7   c                 .    t          |          | _        dS )zSet the parent header.N)r   r   )r3   parents     r5   
set_parentzOutStream.set_parent)  s    +F33r7   c                 V   | j         rrd| _         t          j        | j        d           | j                                         t          j        | j        | j                   t          j        | j                   | j	        r!| j	        \  }}}t          j        |||           d| _        dS )zClose the stream.F    N)r   r   r   r   r  r   r  r   rF   r   	tracebackprint_exceptionr   )r3   etyper   tbs       r5   rF   zOutStream.close-  s     	4!&D HT0%888 %%'''GD143NOOOHT23339 	8#yE5"%eUB777r7   c                     | j         d u S r:   )r   r>   s    r5   r   zOutStream.closed=  s    $&&r7   c                 f      j         rdS d _          fd} j                            |           dS )zuschedule a flush in the IO thread

        call this on write, to indicate that flush should be called soon.
        NTc                  R     j                              j         j                   d S r:   )r   
call_laterflush_interval_flushr>   s   r5   _schedule_in_threadz6OutStream._schedule_flush.<locals>._schedule_in_threadK  s&    M$$T%8$+FFFFFr7   )r   r   r   )r3   r"  s   ` r5   _schedule_flushzOutStream._schedule_flushA  sZ    
  	F"	G 	G 	G 	G 	G 	  !455555r7   c                    | j         r| j         j        | j         j                                        r| j         j        j        t	          j                    j        k    r| j                             | j                   t	          j                    }| j                             |j	                   |
                    | j                  st          dt          j                   dS dS |                                  dS )zStrigger actual zmq send

        send will happen in the background thread
        NzIOStream.flush timed outrZ   )r   r/   rf   r  r$   rl   r   r!  Eventr   waitflush_timeoutr_   r`   ra   )r3   evts     r5   flushzOutStream.flushP  s     O	&2&//11 3&,	0H0J0J0PPP O$$T[111/##CO$$SW---88D.// G 0s~FFFFFFG G
 KKMMMMMr7   c                 :   d| _         d| _        | j        c	 | j                                         nH# t          $ r;}| j        t
          j        urt          d| t
          j                   Y d}~nd}~ww xY w|                                 D ]\  }}|rt          j
                    | j        _        | j        |d}| j                            d||          }| j        D ]} ||          }|  dS | j                            | j        || j                   dS )	zThis is where the actual send happens.

        _flush should generally be called in the IO thread,
        unless the thread has been destroyed (e.g. forked subprocess).
        FNzFlush failed: rZ   )r   textstream)r  )r  )r   r   r   r)  OSErrorr`   ra   r_   _flush_buffersr   r   r   pidr   rr   _hooksr   r   r   )r3   rb   r  datacontentrr   hooks          r5   r!  zOutStream._flushh  s^    $).&9 E	!!!! E E E9CN22.1..S^DDDDE !//11 	 	LFD  $&9;; #'9d;;l&&x&HH
 !K  D$s))C{ # !!O* "   #	 	s   1 
A61A11A6stringreturnc                    | j         }t          |t                    s!dt          |           }t	          |          | j        d	 | j                            |           nH# t          $ r;}| j        t          j	        urt          d| t          j	                   Y d}~nd}~ww xY w| j        d}t          |          |                                  }| j        5  | j        t!          |                                                                       |           ddd           n# 1 swxY w Y   |r0| j        rdS d| _        | j                            | j                   n|                                  t-          |          S )zWrite to current stream after encoding if necessary

        Returns
        -------
        len : int
            number of items from input parameter written to stream.

        z"write() argument must be str, not NzWrite failed: rZ   I/O operation on closed fileT)r   r   strtype	TypeErrorr   r   r-  r`   ra   r_   r   r  r   r   r   	frozensetre   r   r   r!  r#  ro   )r3   r4  r  rr   rb   is_childs         r5   r   zOutStream.write  s    #&#&& 	!EtF||EECC.. 9 E	'''' E E E9CN22.1..S^DDDDE ?"0CS//!..000 	C 	CM)FLLNN334::6BBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 		# - t-1D*O$$T[1111  """6{{s+   A! !
B&+1B!!B&A D))D-0D-c                 j    | j         d}t          |          |D ]}|                     |           dS )zWrite lines to the stream.Nr7  )r   r  r   )r3   sequencerr   r4  s       r5   
writelineszOutStream.writelines  sI    ?"0CS//! 	 	FJJv	 	r7   c                     dS )z$Test whether the stream is writable.Tr   r>   s    r5   writablezOutStream.writable  s    tr7   c              #      K   |                                  }|                                D ]@\  }}|                                }|                                 t	          |          |fV  AdS )z<clear the current buffer and return the current buffer data.N)_rotate_buffersre   getvaluerF   dict)r3   buffersfrozen_parentbufferr1  s        r5   r.  zOutStream._flush_buffers  su      &&((%,]]__ 	, 	,!M6??$$DLLNNN}%%t+++++	, 	,r7   c                     | j         5  | j        }t          t                    | _        ddd           n# 1 swxY w Y   |S )z@Returns the current buffer and replaces it with an empty buffer.N)r   r   r   r   )r3   old_bufferss     r5   rC  zOutStream._rotate_buffers  s~     	2 	2-K'11DM	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 s   !599c                 \    t          | j        d          sg | j        _        | j        j        S )Nhooks)r   r%   rL  r>   s    r5   r0  zOutStream._hooks  s+    t{G,, 	# "DK{  r7   c                 :    | j                             |           dS )a  
        Registers a hook with the thread-local storage.

        Parameters
        ----------
        hook : Any callable object

        Returns
        -------
        Either a publishable message, or `None`.
        The hook callable must return a message from
        the __call__ method if they still require the
        `session.send` method to be called after transformation.
        Returning `None` will halt that execution path, and
        session.send will not be called.
        N)r0  r   r3   r3  s     r5   register_hookzOutStream.register_hook  s     " 	4     r7   c                 ^    	 | j                             |           dS # t          $ r Y dS w xY w)aB  
        Un-registers a hook with the thread-local storage.

        Parameters
        ----------
        hook : Any callable object which has previously been
            registered as a hook.

        Returns
        -------
        bool - `True` if the hook was removed, `False` if it wasn't
            found.
        TF)r0  remover  rN  s     r5   unregister_hookzOutStream.unregister_hook  sD    	Kt$$$4 	 	 	55	s    
,,)NN)%r   r   r   r   r'  r   r   encodingr   r   r	   __annotations__r   r   r6   r   r   setterr   r   r   r  rF   r   r#  r)  r!  r8  intr   r?  rA  r.  rC  r0  rO  rR  r   r7   r5   r   r   ]  s          MNEHD(3-+ + +' ' '6 l& l& l& l& l& l&\ 2 2 X2$ . . .  % % %/ / /4 4 4    ' ' X'6 6 6  0% % %N)C )HSM ) ) ) )V    , , ,   ! ! X!! ! !&    r7   r   )%r   r;   r   r   r   r   r`   r$   r  r~   binasciir   collectionsr   r   r   r   r   typingr	   r
   r   r   r   rK   jupyter_client.sessionr   tornado.ioloopr   zmq.eventloop.zmqstreamr   r   r   r   r   r   r   r   r7   r5   <module>r]     s   4 4
       				 				 



                * * * * * * * * # # # # # # # #       7 7 7 7 7 7 7 7 7 7 7 7 7 7 



 1 1 1 1 1 1 ! ! ! ! ! ! - - - - - - 
	        D0> 0> 0> 0> 0> 0> 0> 0>fd d d d d
 d d d d dr7   