zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
Z±dZ
ã@sjddlmZddlZddlmZddlmZddlmZddlmZej ddd    Gd
d „d ej d ƒZ dS) é)Ú defaultdictN)Úasynccontextmanageré)Ú_core)Ú_util)ÚEventF)ÚeqÚhashc@sPeZdZdZejdd„ddZejeddZejdddZ    e
e dœdd    „ƒZ d
S) Ú    SequenceraØA convenience class for forcing code in different tasks to run in an
    explicit linear order.
 
    Instances of this class implement a ``__call__`` method which returns an
    async context manager. The idea is that you pass a sequence number to
    ``__call__`` to say where this block of code should go in the linear
    sequence. Block 0 starts immediately, and then block N doesn't start until
    block N-1 has finished.
 
    Example:
      An extremely elaborate way to print the numbers 0-5, in order::
 
         async def worker1(seq):
             async with seq(0):
                 print(0)
             async with seq(4):
                 print(4)
 
         async def worker2(seq):
             async with seq(2):
                 print(2)
             async with seq(5):
                 print(5)
 
         async def worker3(seq):
             async with seq(1):
                 print(1)
             async with seq(3):
                 print(3)
 
         async def main():
            seq = trio.testing.Sequencer()
            async with trio.open_nursery() as nursery:
                nursery.start_soon(worker1, seq)
                nursery.start_soon(worker2, seq)
                nursery.start_soon(worker3, seq)
 
    cCsttƒS)N)rr©r r úNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/testing/_sequencer.pyÚ<lambda>8ózSequencer.<lambda>F)ÚfactoryÚinit)Údefaultr)Úpositionc    CsÂ||jkrtd |¡ƒ‚|jr&tdƒ‚|j |¡|dkržz|j| ¡IdHWn<tjk
rŽd|_|j     ¡D] }| 
¡qttdƒ‚YnX|jržtdƒ‚z
dVW5|j|d 
¡XdS)Nz%Attempted to re-use sequence point {}zsequence broken!rTz+Sequencer wait cancelled -- sequence brokené) Ú_claimedÚ RuntimeErrorÚformatÚ_brokenÚaddÚ_sequence_pointsÚwaitrZ    CancelledÚvaluesÚset)ÚselfrÚeventr r r Ú__call__=s$
 
 
zSequencer.__call__N) Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚattrÚibrrrrrÚintrr r r r r
s'ÿr
)Ú    metaclass)Ú collectionsrr$Úasync_generatorrÚrrrÚ DefaultDictÚSetÚsÚFinalr
r r r r Ú<module>s