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
55
56
57
U
¸ý°d !ã@säddlmZddlZddlmZddlZddlZddlmZddlmZddlm    Z    ddlm
Z
ddlm Z dd    lm Z dd
lm Z d d lmZd dlmZd dlmZd dlmZe dƒZej râGdd„deƒZddœdd„ZnddlmZddlmZeeƒdƒZdddœdd„ZGdd „d eƒZe d!d"d#Ze rJd$d%d&œd'd(„ZnejZd)d*d&œd+d,„Zd-dd&œd.d/„Zd-dd&œd0d1„Z d2d3œd4d5dd5dd6œd7d8„Z!Gd9d:„d:ƒZ"d;d5d5d5d<œd=d>„Z#d;d5d5d5d<œd?d@„Z$dAdœdBdC„Z%dS)Dé)Ú annotationsN)ÚContext)ÚAny)Ú    Awaitable)ÚCallable)Ú    Coroutine)ÚOptional)Ú TYPE_CHECKING)ÚTypeVaré)Úmemoized_propertyé)Úexc)ÚProtocol)Ú    TypeGuardÚ_Tc@sNeZdZUded<ded<dddœdd„Zd    d    d
œd d „Zd    d    d œdd„ZdS)ÚgreenletÚboolÚdeadzOptional[Context]Ú
gr_contextúCallable[..., Any]©ÚfnÚdrivercCsdS©N©©ÚselfrrrrúXd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/util/_concurrency_py3k.pyÚ__init__%szgreenlet.__init__r)ÚargÚreturncGsdSrr)rr rrrÚthrow(szgreenlet.throw)Úvaluer!cCsdSrr)rr#rrrÚswitch+szgreenlet.switchN)Ú__name__Ú
__module__Ú __qualname__Ú__annotations__rr"r$rrrrr s
 
r©r!cCsdSrrrrrrÚ
getcurrent.sr*)r*)rrÚ BaseExceptionr)Úer!cCst|tƒ pt|tjtjfƒSr)Ú
isinstanceÚ    ExceptionÚasyncioÚ TimeoutErrorZCancelledError)r,rrrÚis_exit_exception<s
ÿr1c@s&eZdZUded<dddœdd„ZdS)    Ú_AsyncIoGreenletrrrrrcCs$t |||¡||_tr |j|_dSr)rrrÚ_has_gr_contextrrrrrrLsz_AsyncIoGreenlet.__init__N)r%r&r'r(rrrrrr2Is
r2Ú_T_coT)Ú    covariantzAwaitable[_T_co]z%TypeGuard[Coroutine[Any, Any, _T_co]])Ú    awaitabler!cCsdSrr©r6rrrÚ iscoroutineWsr8zAwaitable[Any]ÚNonecCst|ƒr| ¡dSr)r8Úcloser7rrrÚ_safe_cancel_awaitable`sr;z Awaitable[_T]cCs.tƒ}t|tƒs"t|ƒt d¡‚|j |¡S)zÓAwaits an async function in a sync method.
 
    The sync method must be inside a :func:`greenlet_spawn` context.
    :func:`await_only` calls cannot be nested.
 
    :param awaitable: The coroutine to call.
 
    zjgreenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?)r*r-r2r;rÚMissingGreenletrr$)r6ÚcurrentrrrÚ
await_onlygs
 
ÿ    r>cCsFtƒ}t|tƒs:tƒ}| ¡r0t|ƒt d¡‚| |¡S|j     
|¡S)z×Awaits an async function in a sync method.
 
    The sync method must be inside a :func:`greenlet_spawn` context.
    :func:`await_fallback` calls cannot be nested.
 
    :param awaitable: The coroutine to call.
 
    z˜greenlet_spawn has not been called and asyncio event loop is already running; can't call await_fallback() here. Was IO attempted in an unexpected place?) r*r-r2Úget_event_loopÚ
is_runningr;rr<Úrun_until_completerr$)r6r=ÚlooprrrÚawait_fallbacks 
ÿ
rCF)Ú_require_awaitzCallable[..., _T]r)rÚargsrDÚkwargsr!cÏs†t|tƒƒ}d}zX|j||Ž}|jsfd}z|IdH}Wn"tk
rX|jt ¡Ž}YqX| |¡}qW5|`X|r‚|s‚t     
d¡‚|S)aGRuns a sync function ``fn`` in a new greenlet.
 
    The sync function can then use :func:`await_only` to wait for async
    functions.
 
    :param fn: The sync callable to call.
    :param \*args: Positional arguments to pass to the ``fn`` callable.
    :param \*\*kwargs: Keyword arguments to pass to the ``fn`` callable.
    FTNz¶The current operation required an async execution but none was detected. This will usually happen when using a non compatible DBAPI driver. Please ensure that an async DBAPI is used.) r2r*rr$rr+r"ÚsysÚexc_inforZ AwaitRequired)rrDrErFÚcontextZswitch_occurredÚresultr#rrrÚgreenlet_spawns"  ÿrKc@s>eZdZeddœdd„ƒZddœdd„Zddd    d
œd d „Zd S)ÚAsyncAdaptedLockz asyncio.Lockr)cCst ¡Sr)r/ÚLock©rrrrÚmutexÐszAsyncAdaptedLock.mutexrcCst|j ¡ƒSr)rCrOÚacquirerNrrrÚ    __enter__ÖszAsyncAdaptedLock.__enter__rr9)r Úkwr!cOs|j ¡dSr)rOÚrelease)rr rRrrrÚ__exit__ÛszAsyncAdaptedLock.__exit__N)r%r&r'r rOrQrTrrrrrLÏsrLz'Callable[..., Coroutine[Any, Any, Any]])rrErFr!cOs&tƒ}| ¡rtdƒ‚| |||Ž¡S)úfor test suite/ util onlyz]for async run coroutine we expect that no greenlet or event loop is running when we start out)r?r@r.rA©rrErFrBrrrÚ"_util_async_run_coroutine_functionßs ÿrWcOsBtƒ}| ¡s$| t|f|ž|Ž¡Sttƒtƒs4t‚|||ŽSdS)rUN)r?r@rArKr-r*r2ÚAssertionErrorrVrrrÚ_util_async_runís
rYzasyncio.AbstractEventLoopcCs0z
t ¡WStk
r*t ¡ ¡YSXdS)z}vendor asyncio.get_event_loop() for python 3.7 and above.
 
    Python 3.10 deprecates get_event_loop() as a standalone.
 
    N)r/Zget_running_loopÚ RuntimeErrorZget_event_loop_policyr?rrrrr?üs
r?)&Ú
__future__rr/Z contextvarsrrGÚtypingrrrrrr    r
Z langhelpersr ÚrZ util.typingrrrrr*Úhasattrr3r1r2r4r8r;r>rCrKrLrWrYr?rrrrÚ<module>    sJ                 
ý2