§
    cÌc  ã                   óX   — d dl Z d dlZd dlmZmZmZmZmZ  G d„ dej        ¦  «        Z	dS )é    N)ÚOptionalÚListÚTypeÚCallableÚUnionc                   óÊ   ‡ — e Zd ZU dZeeegef                  ed<   ˆ fd„Z	d„ Z
d„ Zdeeegef         deee                  ee         f         fd„Zˆ fd	„Zdˆ fd
„	Zd„ Zˆ xZS )ÚCatchingExceptionThreadz¡A thread that keeps track of exceptions.

    If an exception occurs during the thread execution, it's caught and
    re-raised when the thread is joined().
    Úignored_exceptionsc                 ó$  •— 	 |                      d¦  «        }n## t          $ r t          j        ¦   «         }Y nw xY w t	          ¦   «         j        |i |¤Ž |                      |¦  «         d | _        d | _        t          j	        ¦   «         | _
        d S )NÚ
sync_event)ÚpopÚKeyErrorÚ	threadingÚEventÚsuperÚ__init__Úset_sync_eventÚ	exceptionr
   ÚLockÚlock)ÚselfÚargsÚkwargsr   Ú	__class__s       €ú1/usr/lib/python3/dist-packages/breezy/cethread.pyr   z CatchingExceptionThread.__init__   s›   ø€ ð
	+ØŸš LÑ1Ô1ˆJˆJøÝð 	+ð 	+ð 	+å"œÑ*Ô*ˆJˆJˆJð	+øøøð 	�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ø×Ò˜JÑ'Ô'Ð'ØˆŒØ"&ˆÔÝ”NÑ$Ô$ˆŒ	ˆ	ˆ	s   ƒ ™9¸9c                 ó   — || _         dS )ac  Set the ``sync_event`` event used to synchronize exception catching.

        When the thread uses an event to synchronize itself with another thread
        (setting it when the other thread can wake up from a ``wait`` call),
        the event must be set after catching an exception or the other thread
        will hang.

        Some threads require multiple events and should set the relevant one
        when appropriate.

        Note that the event should be initially cleared so the caller can
        wait() on him and be released when the thread set the event.

        Also note that the thread can use multiple events, setting them as it
        progress, while the caller can chose to wait on any of them. What
        matters is that there is always one event set so that the caller is
        always released when an exception is caught. Re-using the same event is
        therefore risky as the thread itself has no idea about which event the
        caller is waiting on. If the caller has already been released then a
        cleared event won't guarantee that the caller is still waiting on it.
        N)r   )r   Úevents     r   r   z&CatchingExceptionThread.set_sync_event/   s   € ð,  ˆŒˆˆó    c                 óT  — | j         }| j                             ¦   «          	 	 |                      |¦  «         n$# t          $ r |                      |¦  «         ‚ w xY w|                     ¦   «          | j                             ¦   «          dS # | j                             ¦   «          w xY w)a�  Switch to a new ``sync_event`` and set the current one.

        Using this method protects against race conditions while setting a new
        ``sync_event``.

        Note that this allows a caller to wait either on the old or the new
        event depending on whether it wants a fine control on what is happening
        inside a thread.

        :param new: The event that will become ``sync_event``
        N)r   r   Úacquirer   ÚBaseExceptionÚsetÚrelease)r   ÚnewÚcurs      r   Úswitch_and_setz&CatchingExceptionThread.switch_and_setG   s·   € ð ŒoˆØŒ	×ÒÑÔÐð	 ðØ×#Ò# CÑ(Ô(Ð(Ð(øå ð ð ð ð ×#Ò# CÑ(Ô(Ð(Øð	øøøð �GŠG‰IŒIˆIàŒI×ÒÑÔÐÐÐøˆDŒI×ÒÑÔÐÐøøøs   £9 ¸B ¹!AÁB ÂB'ÚignoredNc                 ó¾   ‡— ‰€	d| _         dS t          ‰t          t          f¦  «        rˆfd„| _         dS t          ‰t          ¦  «        rˆfd„| _         dS ‰| _         dS )aÔ  Declare which exceptions will be ignored.

        :param ignored: Can be either:

           - None: all exceptions will be raised,
           - an exception class: the instances of this class will be ignored,
           - a tuple of exception classes: the instances of any class of the
             list will be ignored,
           - a callable: that will be passed the exception object
             and should return True if the exception should be ignored
        Nc                 ó$   •— t          | ‰¦  «        S ©N)Ú
isinstance©Úer'   s    €r   ú<lambda>z@CatchingExceptionThread.set_ignored_exceptions.<locals>.<lambda>t   s   ø€ µ
¸1¸gÑ0FÔ0F€ r   c                 ó>   •— t          | t          ‰¦  «        ¦  «        S r*   )r+   Útupler,   s    €r   r.   z@CatchingExceptionThread.set_ignored_exceptions.<locals>.<lambda>v   s   ø€ µ
¸1½eÀG¹n¼nÑ0MÔ0M€ r   )r
   r+   Ú	Exceptionr0   Úlist)r   r'   s    `r   Úset_ignored_exceptionsz.CatchingExceptionThread.set_ignored_exceptionse   s}   ø€ ð ˆ?Ø&*ˆDÔ#Ð#Ð#Ý˜¥)­UÐ!3Ñ4Ô4ð 	.Ø&FÐ&FÐ&FÐ&FˆDÔ#Ð#Ð#Ý˜¥Ñ&Ô&ð 	.Ø&MÐ&MÐ&MÐ&MˆDÔ#Ð#Ð#à&-ˆDÔ#Ð#Ð#r   c                 ó>  •— | j                              ¦   «          	 	 t          ¦   «                              ¦   «          n(# t          $ r t          j        ¦   «         | _        Y nw xY w| j                              ¦   «          dS # | j                              ¦   «          w xY w)z.Overrides Thread.run to capture any exception.N)	r   Úclearr   Úrunr!   ÚsysÚexc_infor   r"   )r   r   s    €r   r6   zCatchingExceptionThread.runz   s–   ø€ àŒ×ÒÑÔÐð	"ð0Ý‘”—’‘”��øÝ ð 0ð 0ð 0Ý!$¤¡¤�”��ð0øøøð ŒO×ÒÑ!Ô!Ð!Ð!Ð!øˆDŒO×ÒÑ!Ô!Ð!Ð!øøøs&   � > ½B ¾"A#Á B Á"A#Á#B ÂBc                 ó¼   •— t          ¦   «                              |¦  «         | j        �0| j        \  }}}d| _        | j        �|                      |¦  «        s|‚dS dS )z³Overrides Thread.join to raise any exception caught.

        Calling join(timeout=0) will raise the caught exception or return None
        if the thread is still alive.
        N)r   Újoinr   r
   )r   ÚtimeoutÚ	exc_classÚ	exc_valueÚexc_tbr   s        €r   r:   zCatchingExceptionThread.join†   sn   ø€ õ 	‰Œ�Š�WÑÔÐØŒ>Ð%Ø+/¬>Ñ(ˆI�y &Ø!ˆDŒNØÔ'Ð/Ø×2Ò2°9Ñ=Ô=ð 0ð  �ð &Ð%ð 0Ð/r   c                 ó2   — |                       d¬¦  «         dS )zYRaise the caught exception.

        This does nothing if no exception occurred.
        r   )r;   N)r:   )r   s    r   Úpending_exceptionz)CatchingExceptionThread.pending_exception•   s   € ð
 	�	Š	˜!ˆ	ÑÔÐÐÐr   r*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r1   ÚboolÚ__annotations__r   r   r&   r   r   r   r3   r6   r:   r@   Ú__classcell__)r   s   @r   r	   r	      s  ø€ € € € € € ðð ð ! ¨9¨+°tÐ*;Ô!<Ô=Ð=Ð=Ñ=ð%ð %ð %ð %ð %ð  ð  ð  ð0 ð  ð  ð<.¨e°H¸i¸[È$Ð=NÔ4OÐQUÐW[Ð\`ÐajÔ\kÔWlÐnrÐs|Ôn}Ð4}Ô.~ð .ð .ð .ð .ð*
"ð 
"ð 
"ð 
"ð 
"ð ð  ð  ð  ð  ð  ðð ð ð ð ð ð r   r	   )
r7   r   Útypingr   r   r   r   r   ÚThreadr	   © r   r   ú<module>rK      s‡   ðð" €
€
€
Ø Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ðDð Dð Dð Dð D˜iÔ.ñ Dô Dð Dð Dð Dr   