1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
U
Z±d½
ã@sdddlZddlmZddlmZejddddGd    d
„d
ƒƒZejddddGd d „d ed ƒZdS)éNé)Ú_runé)ÚFinalFT)ÚeqÚhashÚslotsc@s@eZdZeƒZe ¡ZejedZejdddZ    e
dd„ƒZ dS)Ú _RunVarToken©ÚdefaultF)r ÚinitcCs||ƒS)N©)ÚclsÚvarr r úHd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_core/_local.pyÚemptysz_RunVarToken.emptyN) Ú__name__Ú
__module__Ú __qualname__ÚobjectÚ    _no_valueÚattrÚibÚ_varÚprevious_valueÚredeemedÚ classmethodrr r r rr        s  r    c@sNeZdZdZeƒZe ¡ZejedZ    efdd„Z
dd„Z dd„Z d    d
„Z d S) ÚRunVarzàThe run-local variant of a context variable.
 
    :class:`RunVar` objects are similar to context variable objects,
    except that they are shared across a single call to :func:`trio.run`
    rather than a single task.
 
    r
cCsxztjjj|WStk
r.tdƒd‚YnFtk
rr||jk    rN|YS|j|jk    rd|jYSt    |ƒd‚YnXdS)z@Gets the value of this :class:`RunVar` for the current run call.ú'Cannot be used outside of a run contextN)
rÚGLOBAL_RUN_CONTEXTÚrunnerÚ_localsÚAttributeErrorÚ RuntimeErrorÚKeyErrorÚ _NO_DEFAULTÚ_defaultÚ LookupError)Úselfr r r rÚget$s
 
z
RunVar.getcCsHz | ¡}Wntk
r*t |¡}Yn Xt||ƒ}|tjjj|<|S)zSSets the value of this :class:`RunVar` for this current run
        call.
 
        )r)r'r    rrrr r!)r(ÚvalueÚ    old_valueÚtokenr r rÚset4s 
z
RunVar.setcCsŒ|dkrtdƒ‚|jrtdƒ‚|j|k    r0tdƒ‚|j}z.|tjkrTtjj    j
  |¡n|tjj    j
|<Wnt k
r€t dƒ‚YnXd|_dS)zlResets the value of this :class:`RunVar` to what it was
        previously specified by the token.
 
        Nztoken must not be noneztoken has already been usedztoken is not for usrT)Ú    TypeErrorrÚ
ValueErrorrrr    rrrr r!Úpopr"r#)r(r,Úpreviousr r rÚresetEs
 
z RunVar.resetcCs d |j¡S)Nz<RunVar name={!r}>)ÚformatÚ_name)r(r r rÚ__repr__^szRunVar.__repr__N)rrrÚ__doc__rr%rrr4r&r)r-r2r5r r r rrs  r)Ú    metaclass)rÚrZ_utilrÚsr    rr r r rÚ<module>s