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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
U
Z±dÝ.ã@sddlmZddlZddlZddlZddlZddlmZmZddl    Z
ddl Z ddl Z ddl mZddlZejdkr¢ddlZe ¡Ze d¡e d¡ZeedƒZnd    d
„Zd d „Zd d„ZGdd„dƒZdd„Zdd„ZGdd„dƒZGdd„deƒZe
  d¡Z!Gdd„deƒZ"dd„Z#dS)é)ÚABCMetaN)ÚwrapsÚupdate_wrapper)Ú
isasyncgenÚntzint raise(int);z!api-ms-win-crt-runtime-l1-1-0.dllÚraisecCst t ¡|¡dS©N)ÚsignalZ pthread_killÚ    threadingÚ    get_ident)Úsignum©r úAd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_util.pyÚ signal_raise@srcCs8zt tjt tj¡¡WdStk
r2YdSXdS)z7Attempt to reliably check if we are in the main thread.TFN)r    ÚSIGINTÚ    getsignalÚ
ValueErrorr r r rÚis_main_threadLs
rcGsÀdd„}z ||Ž}WnVtk
rjt|tjjƒrL| ¡tdj|dƒd‚||ƒrdtd |¡ƒd‚‚YnXt|tjjƒs¼||ƒrtd |¡ƒ‚t|ƒr¦td |¡ƒ‚td t|d    |ƒ¡ƒ‚|S)
NcSs:t|tjjƒrdSt|ddƒdk    r&dS|jjdkr6dSdS)NTZ_asyncio_future_blocking)ZFutureZDeferredF)Ú
isinstanceÚ collectionsÚabcÚ    GeneratorÚgetattrÚ    __class__Ú__name__)Úvaluer r rÚ&_return_value_looks_like_wrong_libraryZs zBcoroutine_or_error.<locals>._return_value_looks_like_wrong_libraryašTrio was expecting an async function, but instead it got a coroutine object {async_fn!r}
 
Probably you did something like:
 
  trio.run({async_fn.__name__}(...))            # incorrect!
  nursery.start_soon({async_fn.__name__}(...))  # incorrect!
 
Instead, you want (notice the parentheses!):
 
  trio.run({async_fn.__name__}, ...)            # correct!
  nursery.start_soon({async_fn.__name__}, ...)  # correct!)Úasync_fnuÊTrio was expecting an async function, but instead it got {!r} â€“ are you trying to use a library written for asyncio/twisted/tornado or similar? That won't work without some sort of compatibility shim.u¥Trio got unexpected {!r} â€“ are you trying to use a library written for asyncio/twisted/tornado or similar? That won't work without some sort of compatibility shim.zEstart_soon expected an async function but got an async generator {!r}zCTrio expected an async function, but {!r} appears to be synchronousÚ __qualname__)    Ú    TypeErrorrrrÚ    CoroutineÚcloseÚformatrr)rÚargsrÚcoror r rÚcoroutine_or_errorYsR  ôÿñýÿûþÿÿÿ
ÿÿr%c@s(eZdZdZdd„Zdd„Zdd„ZdS)    ÚConflictDetectoraDetect when two tasks are about to perform operations that would
    conflict.
 
    Use as a synchronous context manager; if two tasks enter it at the same
    time then the second one raises an error. You can use it when there are
    two pieces of code that *would* collide and need a lock if they ever were
    called at the same time, but that should never happen.
 
    We use this in particular for things like, making sure that two different
    tasks don't call sendall simultaneously on the same stream.
 
    cCs||_d|_dS©NF)Ú_msgÚ_held)ÚselfÚmsgr r rÚ__init__¸szConflictDetector.__init__cCs|jrt |j¡‚nd|_dS)NT)r)ÚtrioZBusyResourceErrorr()r*r r rÚ    __enter__¼szConflictDetector.__enter__cGs
d|_dSr')r))r*r#r r rÚ__exit__ÂszConflictDetector.__exit__N)rÚ
__module__rÚ__doc__r,r.r/r r r rr&ªs r&cs‡‡‡fdd„}|S)z@Similar to wraps, but for async wrappers of non-async functions.cs0ˆ|_d ˆjˆf¡|_d ˆjˆjˆ¡|_|S)NÚ.z,Like :meth:`~{}.{}.{}`, but async.
 
        )rÚjoinrr"r0r1)Úfunc©Ú    attr_nameÚclsÚ wrapped_clsr rÚ    decoratorÉsýzasync_wraps.<locals>.decoratorr )r7r8r6r9r r5rÚ async_wrapsÆs r:csDtƒ‰‡‡‡‡fdd„‰| ¡D]\‰}ˆ d¡s ˆˆˆ|ƒq dS)Ncs˜t|ƒˆkrdSˆ t|ƒ¡t|ddƒ}|dk    r”| d¡r”ˆ|_t|dƒrbd|jkrb||_||_t|t    ƒr”|j
  ¡D]\}}ˆˆd|||ƒqvdS)Nr0ztrio.rr2) ÚidÚaddrÚ
startswithr0ÚhasattrrrrÚtypeÚ__dict__Úitems)ÚqualnameÚnameÚobjÚmodr6Ú
attr_value©Úfix_oneÚ module_nameZobjnameZseen_idsr rrHÛs  
z&fixup_module_metadata.<locals>.fix_oneÚ_)ÚsetrAr=)rIÚ    namespacerDr rGrÚfixup_module_metadataØs
 
rMc@s(eZdZdZdd„Zdd„Zdd„ZdS)    Úgeneric_functiona;Decorator that makes a function indexable, to communicate
    non-inferrable generic type parameters to a static type checker.
 
    If you write::
 
        @generic_function
        def open_memory_channel(max_buffer_size: int) -> Tuple[
            SendChannel[T], ReceiveChannel[T]
        ]: ...
 
    it is valid at runtime to say ``open_memory_channel[bytes](5)``.
    This behaves identically to ``open_memory_channel(5)`` at runtime,
    and currently won't type-check without a mypy plugin or clever stubs,
    but at least it becomes possible to write those.
    cCst||ƒ||_dSr)rÚ_fn)r*Úfnr r rr,s
zgeneric_function.__init__cOs |j||ŽSr)rO)r*r#Úkwargsr r rÚ__call__    szgeneric_function.__call__cCs|Srr )r*rJr r rÚ __getitem__ szgeneric_function.__getitem__N)rr0rr1r,rRrSr r r rrNôsrNcs eZdZdZ‡fdd„Z‡ZS)ÚFinala<Metaclass that enforces a class to be final (i.e., subclass not allowed).
 
    If a class uses this metaclass like this::
 
        class SomeClass(metaclass=Final):
            pass
 
    The metaclass will ensure that no sub class can be created.
 
    Raises
    ------
    - TypeError if a sub class is created
    cs>|D]&}t|tƒrt|j›d|j›dƒ‚qtƒ ||||¡S)Nr2z does not support subclassing)rrTrr0rÚsuperÚ__new__)r7rCÚbasesZ cls_namespaceÚbase©rr rrVs 
ÿz Final.__new__)rr0rr1rVÚ __classcell__r r rYrrTsrTÚTcs>eZdZdZdd„Zejeejejedœ‡fdd„ Z    ‡Z
S)ÚNoPublicConstructoraMetaclass that enforces a class to be final (i.e., subclass not allowed)
    and ensures a private constructor.
 
    If a class uses this metaclass like this::
 
        class SomeClass(metaclass=NoPublicConstructor):
            pass
 
    The metaclass will ensure that no sub class can be created, and that no instance
    can be initialized.
 
    If you try to instantiate your class (SomeClass()), a TypeError will be thrown.
 
    Raises
    ------
    - TypeError if a sub class or an instance is created.
    cOst|j›d|j›dƒ‚dS)Nr2z has no public constructor)rr0r©r7r#rQr r rrR>sÿzNoPublicConstructor.__call__)r7r#rQÚreturncstƒj||ŽSr)rUrRr]rYr rÚ_createCszNoPublicConstructor._create) rr0rr1rRÚtÚTyper[ÚAnyr_rZr r rYrr\+sr\c    Cs€t|dƒst|ƒSz|jjd}Wn&ttfk
rHd |jj¡}YnXz
|j    }Wntk
rp|jj
}YnX|›d|›S)z{Return the fully-qualified name of the async generator function
    that produced the async generator iterator *agen*.
    Úag_coderz<{}>r2) r>ÚreprÚag_frameÚ    f_globalsÚAttributeErrorÚKeyErrorr"rcÚ co_filenamerÚco_name)ZagenÚmodulerBr r rÚ name_asyncgenGs
 
rl)$rrÚosr    ÚsysÚpathlibÚ    functoolsrrÚtypingr`r
rÚasync_generatorrr-rCZcffiZFFIZ_ffiZcdefZdlopenZ_librrrr%r&r:rMrNrTÚTypeVarr[r\rlr r r rÚ<module>s6  
$
 
   Q