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
U
Z±d#ã@svddlZddlZddlZddlZddlZddlmZddlmZddlm    Z    e 
d¡Z ej dd    d
Gd d „d ƒƒZ dS) éNé)Ú name_asyncgené)Ú_run)Ú_coreztrio.async_generator_errorsFT)ÚeqÚslotsc@sReZdZejejdZejedZ    ejddZ
dd„Z dd„Z dd    „Z d
d „Zd S) ÚAsyncGenerators)ÚfactoryF)ÚinitcsF‡fdd„}‡‡fdd„‰‡‡‡fdd„}t ¡ˆ_tj||ddS)NcsBttjdƒrˆj |¡n$d|jjd<ˆjjdk    r>ˆj |¡dS)NZtaskTú@trio_foreign_asyncgen)    ÚhasattrrZGLOBAL_RUN_CONTEXTÚaliveÚaddÚag_frameÚf_localsÚ
prev_hooksÚ    firstiter)Úagen©Úself©úLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_core/_asyncgens.pyr"s
   z0AsyncGenerators.install_hooks.<locals>.firstitercsFz ˆjˆj||d|›ddWn tk
r@ˆj |¡YnXdS)Nzclose asyncgen z  (abandoned))Úname)Zspawn_system_taskÚ _finalize_oneÚ RuntimeErrorÚtrailing_needs_finalizer)rÚ    agen_name)ÚrunnerrrrÚfinalize_in_trio_context0s
ü
z?AsyncGenerators.install_hooks.<locals>.finalize_in_trio_contextcsÀt|ƒ}z|jj d¡ }Wntk
r4d}YnX|rfˆj ˆ||¡tjd|›dt    d|dnVˆj
j dk    r€ˆj
  |¡n<|  ¡}z|  d¡Wntk
rªYnXtd|›dƒ‚dS)    Nr TzAsync generator z§ was garbage collected before it had been exhausted. Surround its use in 'async with aclosing(...):' to ensure that it gets cleaned up as soon as you're done using it.r)Ú
stacklevelÚsourcezNon-Trio async generator z~ awaited something during finalization; install a finalization hook to support this, or wrap it in 'async with aclosing(...):')rrrÚgetÚAttributeErrorÚ entry_queueÚ run_sync_soonÚwarningsÚwarnÚResourceWarningrÚ    finalizerÚacloseÚsendÚ StopIterationr)rrZis_oursÚcloser©rrrrrr)?s6
ÿ
ù 
ÿz0AsyncGenerators.install_hooks.<locals>.finalizer)rr))ÚsysÚget_asyncgen_hooksrÚset_asyncgen_hooks)rrrr)rr.rÚ install_hooks!s
 2
zAsyncGenerators.install_hookscÃs¨t ¡|jkst‚t|jƒdks$t‚t|jƒ|_|j     |j
|j¡t  dd„¡IdH|j  |j ¡|j  ¡|jr¤|j}tƒ|_|D]}| |t|ƒ¡IdHq†qndS)NrcSstjjS©N)rZAbortZFAILED)Ú_rrrÚ<lambda>…óz4AsyncGenerators.finalize_remaining.<locals>.<lambda>)rZ current_taskZ    init_taskÚAssertionErrorÚlenZtasksÚsetrr$r%Z
rescheduleZwait_task_rescheduledÚupdaterÚclearrr)rrÚbatchrrrrÚfinalize_remainingts ÿ
 
"z"AsyncGenerators.finalize_remainingcCstj|jŽdSr3)r/r1rrrrrÚclose°szAsyncGenerators.closec    ÃsXz2tjdd}| ¡| ¡IdHW5QRXWn tk
rRt d|¡YnXdS)NT)ZshieldzÅException ignored during finalization of async generator %r -- surround your use of the generator in 'async with aclosing(...):' to raise exceptions like this in the context where they're generated)rZ CancelScopeÚcancelr*Ú BaseExceptionÚASYNCGEN_LOGGERÚ    exception)rrrZ cancel_scoperrrr³süzAsyncGenerators._finalize_oneN)Ú__name__Ú
__module__Ú __qualname__ÚattrÚibÚweakrefÚWeakSetrr9rrr2r=r>rrrrrr    s      S<r    )rFÚloggingr/r&rHZ_utilrÚrrÚ    getLoggerrAÚsr    rrrrÚ<module>s