zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
U
Z±dÌã@sšddlZddlZddlZddlmZmZmZmZmZm    Z    m
Z
ddl m Z e  d¡Ze
dedefdZeed    œd
d „ZGd d „d eeee dffƒZdS)éN)ÚAnyÚCallableÚDictÚListÚSequenceÚIteratorÚTypeVaré)Ú
Instrumentztrio.abc.InstrumentÚF.)Úbound)ÚfnÚreturncCs|S)N©)r rrúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_core/_instrumentation.pyÚ_publicsrc@s`eZdZdZdZeedœdd„Zeeddœdd    „ƒZ    eeddœd
d „ƒZ
e e dd œd d„Z dS)Ú InstrumentsaŽA collection of `trio.abc.Instrument` organized by hook.
 
    Instrumentation calls are rather expensive, and we don't want a
    rarely-used instrument (like before_run()) to slow down hot
    operations (like before_task_step()). Thus, we cache the set of
    instruments to be called for each hook, and skip the instrumentation
    call if there's nothing currently installed for that hook.
    r)ÚincomingcCs i|d<|D]}| |¡q dS)NÚ_all)Úadd_instrument)ÚselfrÚ
instrumentrrrÚ__init__ szInstruments.__init__N)rrc    Cs²||dkrdSd|d|<zxt|ƒD]j}| d¡r6q&ztt|ƒ}Wntk
r\Yq&YnXt||ƒ}t|tjƒr€|j|kr€q&d|     |i¡|<q&Wn| 
|¡‚YnXdS)zàStart instrumenting the current run loop with the given instrument.
 
        Args:
          instrument (trio.abc.Instrument): The instrument to activate.
 
        If ``instrument`` is already active, does nothing.
 
        rNÚ_) ÚdirÚ
startswithÚgetattrr
ÚAttributeErrorÚ
isinstanceÚtypesÚ
MethodTypeÚ__func__Ú
setdefaultÚremove_instrument)rrÚnameZ    prototypeÚimplrrrr%s$
 
 
 
 
zInstruments.add_instrumentcCs@|d |¡t| ¡ƒD] \}}||kr||=|s||=qdS)a¹Stop instrumenting the current run loop with the given instrument.
 
        Args:
          instrument (trio.abc.Instrument): The instrument to de-activate.
 
        Raises:
          KeyError: if the instrument is not currently active. This could
              occur either because you never added it, or because you added it
              and then it raised an unhandled exception and was automatically
              deactivated.
 
        rN)ÚpopÚlistÚitems)rrÚhooknameZ instrumentsrrrr#Cs zInstruments.remove_instrument)r)Úargsrc    GsNt||ƒD]<}zt||ƒ|ŽWq | |¡t d||¡Yq Xq dS)aCall hookname(*args) on each applicable instrument.
 
        You must first check whether there are any instruments installed for
        that hook, e.g.::
 
            if "before_task_step" in instruments:
                instruments.call("before_task_step", task)
        zPException raised when calling %r on instrument %r. Instrument has been disabled.N)r'rr#ÚINSTRUMENT_LOGGERÚ    exception)rr)r*rrrrÚcallYs    
üzInstruments.call)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__rr
rrrr#Ústrrr-rrrrrs    r)ÚloggingrÚattrÚtypingrrrrrrrÚ_abcr
Ú    getLoggerr+r rr3rrrrrÚ<module>s$