-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathasyncio-runner.po
More file actions
280 lines (239 loc) · 9.5 KB
/
asyncio-runner.po
File metadata and controls
280 lines (239 loc) · 9.5 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-08 15:25+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../../library/asyncio-runner.rst:6
msgid "Runners"
msgstr "Runners (執行器)"
#: ../../library/asyncio-runner.rst:8
msgid "**Source code:** :source:`Lib/asyncio/runners.py`"
msgstr "**原始碼:**\\ :source:`Lib/asyncio/runners.py`"
#: ../../library/asyncio-runner.rst:11
msgid ""
"This section outlines high-level asyncio primitives to run asyncio code."
msgstr "這個章節概述用於執行 asyncio 程式碼的高階 asyncio 原語。"
#: ../../library/asyncio-runner.rst:13
msgid ""
"They are built on top of an :ref:`event loop <asyncio-event-loop>` with the "
"aim to simplify async code usage for common wide-spread scenarios."
msgstr ""
"他們是基於一個\\ :ref:`事件迴圈 <asyncio-event-loop>`,目的是為了簡化常見且廣"
"泛運用場景的非同步程式碼。"
#: ../../library/asyncio-runner.rst:23
msgid "Running an asyncio Program"
msgstr "運行一個 asyncio 程式"
#: ../../library/asyncio-runner.rst:27
msgid "Execute *coro* in an asyncio event loop and return the result."
msgstr "在 asyncio 事件迴圈中執行 *coro* 並回傳結果。"
#: ../../library/asyncio-runner.rst:29 ../../library/asyncio-runner.rst:121
msgid "The argument can be any awaitable object."
msgstr "該引數可以是任何可等待物件 (awaitable object)。"
#: ../../library/asyncio-runner.rst:31
msgid ""
"This function runs the awaitable, taking care of managing the asyncio event "
"loop, *finalizing asynchronous generators*, and closing the executor."
msgstr ""
"這個函式負責運行被傳入的可等待物件、管理 asyncio 的事件迴圈、*終結非同步產生器*\\ 以"
"及關閉執行器。"
#: ../../library/asyncio-runner.rst:35 ../../library/asyncio-runner.rst:131
msgid ""
"This function cannot be called when another asyncio event loop is running in "
"the same thread."
msgstr "當另一個非同步事件迴圈在同一執行緒中執行時,無法呼叫此函式。"
#: ../../library/asyncio-runner.rst:38 ../../library/asyncio-runner.rst:97
msgid ""
"If *debug* is ``True``, the event loop will be run in debug mode. ``False`` "
"disables debug mode explicitly. ``None`` is used to respect the "
"global :ref:`asyncio-debug-mode` settings."
msgstr ""
"如果 *debug* 為 ``True``,事件迴圈會以除錯模式執行。``False`` 則會關閉除錯模"
"式。``None`` 則會優先使用\\ :ref:`除錯模式 <asyncio-debug-mode>`\\ 的全域設"
"定。"
#: ../../library/asyncio-runner.rst:42
msgid ""
"If *loop_factory* is not ``None``, it is used to create a new event loop; "
"otherwise :func:`asyncio.new_event_loop` is used. The loop is closed at the "
"end. This function should be used as a main entry point for asyncio "
"programs, and should ideally only be called once. It is recommended to use "
"*loop_factory* to configure the event loop instead of policies. "
"Passing :class:`asyncio.EventLoop` allows running asyncio without the policy "
"system."
msgstr ""
"如果 *loop_factory* 不為 ``None``,它會被用於建立一個新的事件迴圈;否則會改"
"用 :func:`asyncio.new_event_loop`。迴圈會在最後關閉。這個函式應該要作為"
"asyncio 程式的主要進入點,且理想上僅會被呼叫一次。推薦使用 *loop_factory* 來"
"設定事件迴圈時而不是使用 policies(政策)。傳遞 :class:`asyncio.EventLoop` 可"
"以讓 asyncio 在沒有政策系統的情況下運行。"
#: ../../library/asyncio-runner.rst:50
msgid ""
"The executor is given a timeout duration of 5 minutes to shutdown. If the "
"executor hasn't finished within that duration, a warning is emitted and the "
"executor is closed."
msgstr ""
#: ../../library/asyncio-runner.rst:54
msgid "Example::"
msgstr "範例: ::"
#: ../../library/asyncio-runner.rst:56
msgid ""
"async def main():\n"
" await asyncio.sleep(1)\n"
" print('hello')\n"
"\n"
"asyncio.run(main())"
msgstr ""
"async def main():\n"
" await asyncio.sleep(1)\n"
" print('hello')\n"
"\n"
"asyncio.run(main())"
#: ../../library/asyncio-runner.rst:64
msgid "Updated to use :meth:`loop.shutdown_default_executor`."
msgstr ""
#: ../../library/asyncio-runner.rst:69
msgid ""
"*debug* is ``None`` by default to respect the global debug mode settings."
msgstr ""
#: ../../library/asyncio-runner.rst:73
msgid "Added *loop_factory* parameter."
msgstr "新增 *loop_factory* 參數。"
#: ../../library/asyncio-runner.rst:77 ../../library/asyncio-runner.rst:136
msgid "*coro* can be any awaitable object."
msgstr ""
#: ../../library/asyncio-runner.rst:81
msgid ""
"The :mod:`!asyncio` policy system is deprecated and will be removed in "
"Python 3.16; from there on, an explicit *loop_factory* is needed to "
"configure the event loop."
msgstr ""
#: ../../library/asyncio-runner.rst:87
msgid "Runner context manager"
msgstr ""
#: ../../library/asyncio-runner.rst:91
msgid ""
"A context manager that simplifies *multiple* async function calls in the "
"same context."
msgstr ""
#: ../../library/asyncio-runner.rst:94
msgid ""
"Sometimes several top-level async functions should be called in the "
"same :ref:`event loop <asyncio-event-loop>` and :class:`contextvars.Context`."
msgstr ""
#: ../../library/asyncio-runner.rst:101
msgid ""
"*loop_factory* could be used for overriding the loop creation. It is the "
"responsibility of the *loop_factory* to set the created loop as the current "
"one. By default :func:`asyncio.new_event_loop` is used and set as current "
"event loop with :func:`asyncio.set_event_loop` if *loop_factory* is ``None``."
msgstr ""
#: ../../library/asyncio-runner.rst:106
msgid ""
"Basically, :func:`asyncio.run` example can be rewritten with the runner "
"usage::"
msgstr ""
#: ../../library/asyncio-runner.rst:108
msgid ""
"async def main():\n"
" await asyncio.sleep(1)\n"
" print('hello')\n"
"\n"
"with asyncio.Runner() as runner:\n"
" runner.run(main())"
msgstr ""
"async def main():\n"
" await asyncio.sleep(1)\n"
" print('hello')\n"
"\n"
"with asyncio.Runner() as runner:\n"
" runner.run(main())"
#: ../../library/asyncio-runner.rst:119
msgid "Execute *coro* in the embedded event loop."
msgstr ""
#: ../../library/asyncio-runner.rst:123
msgid "If the argument is a coroutine, it is wrapped in a Task."
msgstr ""
#: ../../library/asyncio-runner.rst:125
msgid ""
"An optional keyword-only *context* argument allows specifying a "
"custom :class:`contextvars.Context` for the code to run in. The runner's "
"default context is used if context is ``None``."
msgstr ""
#: ../../library/asyncio-runner.rst:129
msgid "Returns the awaitable's result or raises an exception."
msgstr ""
#: ../../library/asyncio-runner.rst:140
msgid "Close the runner."
msgstr ""
#: ../../library/asyncio-runner.rst:142
msgid ""
"Finalize asynchronous generators, shutdown default executor, close the event "
"loop and release embedded :class:`contextvars.Context`."
msgstr ""
#: ../../library/asyncio-runner.rst:147
msgid "Return the event loop associated with the runner instance."
msgstr ""
#: ../../library/asyncio-runner.rst:151
msgid ""
":class:`Runner` uses the lazy initialization strategy, its constructor "
"doesn't initialize underlying low-level structures."
msgstr ""
#: ../../library/asyncio-runner.rst:154
msgid ""
"Embedded *loop* and *context* are created at the :keyword:`with` body "
"entering or the first call of :meth:`run` or :meth:`get_loop`."
msgstr ""
#: ../../library/asyncio-runner.rst:159
msgid "Handling Keyboard Interruption"
msgstr ""
#: ../../library/asyncio-runner.rst:163
msgid ""
"When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-"
"C`, :exc:`KeyboardInterrupt` exception is raised in the main thread by "
"default. However this doesn't work with :mod:`asyncio` because it can "
"interrupt asyncio internals and can hang the program from exiting."
msgstr ""
#: ../../library/asyncio-runner.rst:168
msgid ""
"To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as "
"follows:"
msgstr ""
#: ../../library/asyncio-runner.rst:170
msgid ""
":meth:`asyncio.Runner.run` installs a custom :const:`signal.SIGINT` handler "
"before any user code is executed and removes it when exiting from the "
"function."
msgstr ""
#: ../../library/asyncio-runner.rst:172
msgid ""
"The :class:`~asyncio.Runner` creates the main task for the passed coroutine "
"for its execution."
msgstr ""
#: ../../library/asyncio-runner.rst:174
msgid ""
"When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal "
"handler cancels the main task by calling :meth:`asyncio.Task.cancel` which "
"raises :exc:`asyncio.CancelledError` inside the main task. This causes the "
"Python stack to unwind, ``try/except`` and ``try/finally`` blocks can be "
"used for resource cleanup. After the main task is "
"cancelled, :meth:`asyncio.Runner.run` raises :exc:`KeyboardInterrupt`."
msgstr ""
#: ../../library/asyncio-runner.rst:180
msgid ""
"A user could write a tight loop which cannot be interrupted "
"by :meth:`asyncio.Task.cancel`, in which case the second "
"following :kbd:`Ctrl-C` immediately raises the :exc:`KeyboardInterrupt` "
"without cancelling the main task."
msgstr ""