
    ,hI                    N   U d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
 d dlmZ ddlmZ  e	d      Z e	d	      Zdd
ZddZddZddZ e       Zded<   i Zded<    ed       G d d             Z G d dej2                        Z G d dee         Z G d dee         Zy)    )annotationsN)	dataclass)AnyGenericLiteralTypeVaroverload)WeakKeyDictionary   )get_async_backendTDc                 P   K   t               j                          d{    y7 w)z
    Check for cancellation and allow the scheduler to switch to another task.

    Equivalent to (but more efficient than)::

        await checkpoint_if_cancelled()
        await cancel_shielded_checkpoint()


    .. versionadded:: 3.0

    N)r   
checkpoint     P/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/anyio/lowlevel.pyr   r      s      

(
(
***   &$&c                 P   K   t               j                          d{    y7 w)z
    Enter a checkpoint if the enclosing cancel scope has been cancelled.

    This does not allow the scheduler to switch to a different task.

    .. versionadded:: 3.0

    N)r   checkpoint_if_cancelledr   r   r   r   r      s      

5
5
777r   c                 P   K   t               j                          d{    y7 w)z
    Allow the scheduler to switch to another task but without checking for cancellation.

    Equivalent to (but potentially more efficient than)::

        with CancelScope(shield=True):
            await checkpoint()


    .. versionadded:: 3.0

    N)r   cancel_shielded_checkpointr   r   r   r   r   *   s      

8
8
:::r   c                 2    t               j                         S )ze
    Return a backend specific token object that can be used to get back to the event
    loop.

    )r   current_tokenr   r   r   r   r   :   s     ,,..r   z&WeakKeyDictionary[Any, dict[str, Any]]	_run_varszdict[Any, _TokenWrapper]_token_wrappersT)frozenc                      e Zd ZU dZded<   y)_TokenWrapper)_token__weakref__objectr    N)__name__
__module____qualname__	__slots____annotations__r   r   r   r   r   G   s    'INr   r   c                  .    e Zd Z ej                         Zy)_NoValueSetN)r#   r$   r%   enumautoNO_VALUE_SETr   r   r   r)   r)   M   s    499;Lr   r)   c                      e Zd ZdZddZy)RunvarToken_var_value	_redeemedc                .    || _         || _        d| _        y )NFr/   )selfvarvalues      r   __init__zRunvarToken.__init__T   s    	=Br   N)r5   z	RunVar[T]r6   %T | Literal[_NoValueSet.NO_VALUE_SET])r#   r$   r%   r&   r7   r   r   r   r.   r.   Q   s    -Ir   r.   c                      e Zd ZU dZdZej                  Zded<    e       Z	ded<   ef	 	 	 ddZ
edd       Zedd	       Zedd
       Zef	 	 	 ddZddZddZddZy)RunVarz[
    Like a :class:`~contextvars.ContextVar`, except scoped to the running event loop.
    _name_defaultz!Literal[_NoValueSet.NO_VALUE_SET]r,   zset[_TokenWrapper]r   c                     || _         || _        y Nr;   )r4   namedefaults      r   r7   zRunVar.__init__e   s     
r   c                b    t               }	 t        |   S # t        $ r i x}t        |<   |cY S w xY wr?   )r   r   KeyError)r4   tokenrun_varss      r   _current_varszRunVar._current_varsk   s<    	U## 	*,,Hy'O	s    ..c                     y r?   r   r4   rA   s     r   getz
RunVar.gett   s    (+r   c                     y r?   r   r4   s    r   rI   z
RunVar.getw   s    r   c                   	 | j                   | j                     S # t        $ rC |t        j                  ur|cY S | j
                  t        j                  ur| j
                  cY S Y nw xY wt        d| j                   d      )NzRun variable "z!" has no value and no default set)rF   r<   rC   r:   r,   r=   LookupErrorrH   s     r   rI   z
RunVar.getz   s    	%%%djj11 	%f111f&9&99}}$ :	% TZZL(IJ
 	
s    A'(A'&A'c                    | j                   }t        | |j                  | j                  t        j
                              }||| j                  <   |S r?   )rF   r.   rI   r<   r:   r,   )r4   r6   current_varsrD   s       r   setz
RunVar.set   sC    ))D,"2"24::v?R?R"ST#(TZZ r   c                \   |j                   | urt        d      |j                  rt        d      |j                  t        j
                  u r 	 | j                  | j                  = d|_        y |j                  | j                  | j                  <   d|_        y # t        $ r
 Y d|_        y w xY w)Nz)This token does not belong to this RunVarz This token has already been usedT)	r0   
ValueErrorr2   r1   r)   r,   rF   r<   rC   )r4   rD   s     r   resetzRunVar.reset   s    ::T!HII???@@<<;333&&tzz2  .3\\Dtzz*   s   B 	B+*B+c                "    d| j                   dS )Nz<RunVar name=>)r<   rK   s    r   __repr__zRunVar.__repr__   s    tzznA..r   N)r@   strrA   r8   )returnzdict[str, T])rA   r   rX   T | D)rX   r   )rA   z%D | Literal[_NoValueSet.NO_VALUE_SET]rX   rY   )r6   r   rX   RunvarToken[T])rD   rZ   rX   None)rX   rW   )r#   r$   r%   __doc__r&   r)   r,   r'   rP   r   r7   propertyrF   r	   rI   rS   rV   r   r   r   r:   r:   Z   s     $I6A6N6NL3N*-%O'/ KW  "G    + +  @L
<
	
"/r   r:   )rX   r[   )rX   r"   )
__future__r   r*   dataclassesr   typingr   r   r   r   r	   weakrefr
   _core._eventloopr   r   r   r   r   r   r   r   r'   r   r   Enumr)   r.   r:   r   r   r   <module>rd      s    "  ! ; ; % /CLCL+ 	8; / 5F4G	1 G,.) . $  
$)) '!* G/WQZ G/r   