8
8
msgstr ""
9
9
"Project-Id-Version :Python 3.13\n "
10
10
"Report-Msgid-Bugs-To :\n "
11
- "POT-Creation-Date :2024-09-03 11:11+0800 \n "
11
+ "POT-Creation-Date :2025-05-17 00:18+0000 \n "
12
12
"PO-Revision-Date :2023-02-18 14:17+0800\n "
13
13
"Last-Translator :Matt Wang <mattwang44gmail.com>\n "
14
14
"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -101,15 +101,6 @@ msgstr "啟用除錯模式時:"
101
101
102
102
#: ../../library/asyncio-dev.rst:49
103
103
msgid ""
104
- "asyncio checks for :ref:`coroutines that were not awaited <asyncio-coroutine-"
105
- "not-scheduled>` and logs them; this mitigates the\" forgotten await\" "
106
- "pitfall."
107
- msgstr ""
108
- "asyncio 會檢查\\ :ref:`未被等待的協程 <asyncio-coroutine-not-scheduled>`\\ 並"
109
- "記錄他們;這會減輕\" 被遺忘的等待 (forgotten await)\" 問題。"
110
-
111
- #: ../../library/asyncio-dev.rst:53
112
- msgid ""
113
104
"Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` and :meth:"
114
105
"`loop.call_at` methods) raise an exception if they are called from a wrong "
115
106
"thread."
@@ -118,15 +109,15 @@ msgstr ""
118
109
"call_soon` 和 :meth:`loop.call_at` 方法),如果從錯誤的執行緒呼叫就會引發例"
119
110
"外。"
120
111
121
- #: ../../library/asyncio-dev.rst:57
112
+ #: ../../library/asyncio-dev.rst:53
122
113
msgid ""
123
114
"The execution time of the I/O selector is logged if it takes too long to "
124
115
"perform an I/O operation."
125
116
msgstr ""
126
117
"如果執行一個 I/O 操作花費的時間太長,則將 I/O 選擇器 (selector) 的執行時間記"
127
118
"錄到日誌中。"
128
119
129
- #: ../../library/asyncio-dev.rst:60
120
+ #: ../../library/asyncio-dev.rst:56
130
121
msgid ""
131
122
"Callbacks taking longer than 100 milliseconds are logged. The :attr:`loop."
132
123
"slow_callback_duration` attribute can be used to set the minimum execution "
@@ -136,11 +127,11 @@ msgstr ""
136
127
"slow_callback_duration` 可用於設定以秒為單位的最小執行持續時間,超過這個值執"
137
128
"行時間就會被視為\" 緩慢\" 。"
138
129
139
- #: ../../library/asyncio-dev.rst:68
130
+ #: ../../library/asyncio-dev.rst:64
140
131
msgid "Concurrency and Multithreading"
141
132
msgstr "並行性和多執行緒 (Concurrency and Multithreading)"
142
133
143
- #: ../../library/asyncio-dev.rst:70
134
+ #: ../../library/asyncio-dev.rst:66
144
135
msgid ""
145
136
"An event loop runs in a thread (typically the main thread) and executes all "
146
137
"callbacks and Tasks in its thread. While a Task is running in the event "
@@ -153,19 +144,19 @@ msgstr ""
153
144
"運行。當一個 Task 執行一個 ``await`` 運算式時,正在執行的 Task 會被暫停,而事"
154
145
"件迴圈會執行下一個 Task。"
155
146
156
- #: ../../library/asyncio-dev.rst:76
147
+ #: ../../library/asyncio-dev.rst:72
157
148
msgid ""
158
149
"To schedule a :term:`callback` from another OS thread, the :meth:`loop."
159
150
"call_soon_threadsafe` method should be used. Example::"
160
151
msgstr ""
161
152
"要從不同的 OS 執行緒為一個 :term:`callback` 排程,應該使用 :meth:`loop."
162
153
"call_soon_threadsafe` 方法。例如: ::"
163
154
164
- #: ../../library/asyncio-dev.rst:79
155
+ #: ../../library/asyncio-dev.rst:75
165
156
msgid "loop.call_soon_threadsafe(callback, *args)"
166
157
msgstr "loop.call_soon_threadsafe(callback, *args)"
167
158
168
- #: ../../library/asyncio-dev.rst:81
159
+ #: ../../library/asyncio-dev.rst:77
169
160
msgid ""
170
161
"Almost all asyncio objects are not thread safe, which is typically not a "
171
162
"problem unless there is code that works with them from outside of a Task or "
@@ -176,11 +167,11 @@ msgstr ""
176
167
"在 Task 或回呼函式之外有程式需要和它們一起運作。如果需要這樣的程式來呼叫低階 "
177
168
"asyncio API,應該使用 :meth:`loop.call_soon_threadsafe` 方法,例如: ::"
178
169
179
- #: ../../library/asyncio-dev.rst:87
170
+ #: ../../library/asyncio-dev.rst:83
180
171
msgid "loop.call_soon_threadsafe(fut.cancel)"
181
172
msgstr "loop.call_soon_threadsafe(fut.cancel)"
182
173
183
- #: ../../library/asyncio-dev.rst:89
174
+ #: ../../library/asyncio-dev.rst:85
184
175
msgid ""
185
176
"To schedule a coroutine object from a different OS thread, the :func:"
186
177
"`run_coroutine_threadsafe` function should be used. It returns a :class:"
@@ -190,7 +181,7 @@ msgstr ""
190
181
"`run_coroutine_threadsafe` 函式。它會回傳一個 :class:`concurrent.futures."
191
182
"Future` 以存取結果: ::"
192
183
193
- #: ../../library/asyncio-dev.rst:93
184
+ #: ../../library/asyncio-dev.rst:89
194
185
msgid ""
195
186
"async def coro_func():\n"
196
187
" return await asyncio.sleep(1, 42)\n"
@@ -202,11 +193,11 @@ msgid ""
202
193
"result = future.result()"
203
194
msgstr ""
204
195
205
- #: ../../library/asyncio-dev.rst:102
196
+ #: ../../library/asyncio-dev.rst:98
206
197
msgid "To handle signals the event loop must be run in the main thread."
207
198
msgstr "為了能夠處理訊號,事件迴圈必須於主執行緒中運行。"
208
199
209
- #: ../../library/asyncio-dev.rst:105
200
+ #: ../../library/asyncio-dev.rst:101
210
201
msgid ""
211
202
"The :meth:`loop.run_in_executor` method can be used with a :class:"
212
203
"`concurrent.futures.ThreadPoolExecutor` to execute blocking code in a "
@@ -217,7 +208,7 @@ msgstr ""
217
208
"ThreadPoolExecutor` 一起使用,這能夠在作業系統上另一個不同的執行緒中執行阻塞"
218
209
"程式,且避免阻塞執行事件迴圈的執行緒。"
219
210
220
- #: ../../library/asyncio-dev.rst:110
211
+ #: ../../library/asyncio-dev.rst:106
221
212
msgid ""
222
213
"There is currently no way to schedule coroutines or callbacks directly from "
223
214
"a different process (such as one started with :mod:`multiprocessing`). The :"
@@ -237,11 +228,11 @@ msgstr ""
237
228
"run_in_executor` 方法也可和 :class:`concurrent.futures.ProcessPoolExecutor` "
238
229
"搭配使用,以在另一個行程中執行程式。"
239
230
240
- #: ../../library/asyncio-dev.rst:124
231
+ #: ../../library/asyncio-dev.rst:120
241
232
msgid "Running Blocking Code"
242
233
msgstr "執行阻塞的程式"
243
234
244
- #: ../../library/asyncio-dev.rst:126
235
+ #: ../../library/asyncio-dev.rst:122
245
236
msgid ""
246
237
"Blocking (CPU-bound) code should not be called directly. For example, if a "
247
238
"function performs a CPU-intensive calculation for 1 second, all concurrent "
@@ -250,7 +241,7 @@ msgstr ""
250
241
"不應該直接呼叫阻塞(CPU 密集型)程式。例如一個執行 1 秒 CPU 密集型計算的函"
251
242
"式,那麼所有並行非同步 Tasks 和 IO 操作都會被延遲 1 秒。"
252
243
253
- #: ../../library/asyncio-dev.rst:131
244
+ #: ../../library/asyncio-dev.rst:127
254
245
msgid ""
255
246
"An executor can be used to run a task in a different thread or even in a "
256
247
"different process to avoid blocking the OS thread with the event loop. See "
@@ -260,29 +251,29 @@ msgstr ""
260
251
"以避免使用事件迴圈阻塞 OS 執行緒。詳情請見 :meth:`loop.run_in_executor` 方"
261
252
"法。"
262
253
263
- #: ../../library/asyncio-dev.rst:140
254
+ #: ../../library/asyncio-dev.rst:136
264
255
msgid "Logging"
265
256
msgstr "日誌記錄"
266
257
267
- #: ../../library/asyncio-dev.rst:142
258
+ #: ../../library/asyncio-dev.rst:138
268
259
msgid ""
269
260
"asyncio uses the :mod:`logging` module and all logging is performed via the "
270
261
"``\" asyncio\" `` logger."
271
262
msgstr ""
272
263
"asyncio 使用 :mod:`logging` 模組,所有日誌記錄都是透過 ``\" asyncio\" `` "
273
264
"logger 執行的。"
274
265
275
- #: ../../library/asyncio-dev.rst:145
266
+ #: ../../library/asyncio-dev.rst:141
276
267
msgid ""
277
268
"The default log level is :py:const:`logging.INFO`, which can be easily "
278
269
"adjusted::"
279
270
msgstr "日誌級別被預設為 :py:const:`logging.INFO`,它可以很容易地被調整: ::"
280
271
281
- #: ../../library/asyncio-dev.rst:148
272
+ #: ../../library/asyncio-dev.rst:144
282
273
msgid "logging.getLogger(\" asyncio\" ).setLevel(logging.WARNING)"
283
274
msgstr "logging.getLogger(\" asyncio\" ).setLevel(logging.WARNING)"
284
275
285
- #: ../../library/asyncio-dev.rst:151
276
+ #: ../../library/asyncio-dev.rst:147
286
277
msgid ""
287
278
"Network logging can block the event loop. It is recommended to use a "
288
279
"separate thread for handling logs or use non-blocking IO. For example, see :"
@@ -291,11 +282,11 @@ msgstr ""
291
282
"網路日誌記錄可能會阻塞事件迴圈。建議使用獨立的執行緒來處理日誌或使用非阻塞 "
292
283
"IO,範例請參見 :ref:`blocking-handlers`。"
293
284
294
- #: ../../library/asyncio-dev.rst:159
285
+ #: ../../library/asyncio-dev.rst:155
295
286
msgid "Detect never-awaited coroutines"
296
287
msgstr "偵測從未被等待的 (never-awaited) 協程"
297
288
298
- #: ../../library/asyncio-dev.rst:161
289
+ #: ../../library/asyncio-dev.rst:157
299
290
msgid ""
300
291
"When a coroutine function is called, but not awaited (e.g. ``coro()`` "
301
292
"instead of ``await coro()``) or the coroutine is not scheduled with :meth:"
@@ -305,7 +296,7 @@ msgstr ""
305
296
"者協程沒有透過 :meth:`asyncio.create_task` 被排程,asyncio 將會發出 :exc:"
306
297
"`RuntimeWarning`: ::"
307
298
308
- #: ../../library/asyncio-dev.rst:166
299
+ #: ../../library/asyncio-dev.rst:162
309
300
msgid ""
310
301
"import asyncio\n"
311
302
"\n"
@@ -318,23 +309,23 @@ msgid ""
318
309
"asyncio.run(main())"
319
310
msgstr ""
320
311
321
- #: ../../library/asyncio-dev.rst:176 ../../library/asyncio-dev.rst:221
312
+ #: ../../library/asyncio-dev.rst:172 ../../library/asyncio-dev.rst:217
322
313
msgid "Output::"
323
314
msgstr "輸出: ::"
324
315
325
- #: ../../library/asyncio-dev.rst:178
316
+ #: ../../library/asyncio-dev.rst:174
326
317
msgid ""
327
318
"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n"
328
319
" test()"
329
320
msgstr ""
330
321
"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n"
331
322
" test()"
332
323
333
- #: ../../library/asyncio-dev.rst:181 ../../library/asyncio-dev.rst:237
324
+ #: ../../library/asyncio-dev.rst:177 ../../library/asyncio-dev.rst:233
334
325
msgid "Output in debug mode::"
335
326
msgstr "除錯模式中的輸出: ::"
336
327
337
- #: ../../library/asyncio-dev.rst:183
328
+ #: ../../library/asyncio-dev.rst:179
338
329
msgid ""
339
330
"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n"
340
331
"Coroutine created at (most recent call last)\n"
@@ -358,26 +349,26 @@ msgstr ""
358
349
" test()\n"
359
350
" test()"
360
351
361
- #: ../../library/asyncio-dev.rst:194
352
+ #: ../../library/asyncio-dev.rst:190
362
353
msgid ""
363
354
"The usual fix is to either await the coroutine or call the :meth:`asyncio."
364
355
"create_task` function::"
365
356
msgstr ""
366
357
"常用的修復方法是去等待協程或者呼叫 :meth:`asyncio.create_task` 函式: ::"
367
358
368
- #: ../../library/asyncio-dev.rst:197
359
+ #: ../../library/asyncio-dev.rst:193
369
360
msgid ""
370
361
"async def main():\n"
371
362
" await test()"
372
363
msgstr ""
373
364
"async def main():\n"
374
365
" await test()"
375
366
376
- #: ../../library/asyncio-dev.rst:202
367
+ #: ../../library/asyncio-dev.rst:198
377
368
msgid "Detect never-retrieved exceptions"
378
369
msgstr "偵測從未被取得的 (never-retrieved) 例外"
379
370
380
- #: ../../library/asyncio-dev.rst:204
371
+ #: ../../library/asyncio-dev.rst:200
381
372
msgid ""
382
373
"If a :meth:`Future.set_exception` is called but the Future object is never "
383
374
"awaited on, the exception would never be propagated to the user code. In "
@@ -388,11 +379,11 @@ msgstr ""
388
379
"傳播 (propagate) 到使用者程式。在這種情況下,當 Future 物件被垃圾回收 "
389
380
"(garbage collected) 時,asyncio 將發出一則日誌訊息。"
390
381
391
- #: ../../library/asyncio-dev.rst:209
382
+ #: ../../library/asyncio-dev.rst:205
392
383
msgid "Example of an unhandled exception::"
393
384
msgstr "未處理例外的例子: ::"
394
385
395
- #: ../../library/asyncio-dev.rst:211
386
+ #: ../../library/asyncio-dev.rst:207
396
387
msgid ""
397
388
"import asyncio\n"
398
389
"\n"
@@ -414,7 +405,7 @@ msgstr ""
414
405
"\n"
415
406
"asyncio.run(main())"
416
407
417
- #: ../../library/asyncio-dev.rst:223
408
+ #: ../../library/asyncio-dev.rst:219
418
409
msgid ""
419
410
"Task exception was never retrieved\n"
420
411
"future: <Task finished coro=<bug() done, defined at test.py:3>\n"
@@ -434,19 +425,19 @@ msgstr ""
434
425
" raise Exception(\" not consumed\" )\n"
435
426
"Exception: not consumed"
436
427
437
- #: ../../library/asyncio-dev.rst:232
428
+ #: ../../library/asyncio-dev.rst:228
438
429
msgid ""
439
430
":ref:`Enable the debug mode <asyncio-debug-mode>` to get the traceback where "
440
431
"the task was created::"
441
432
msgstr ""
442
433
":ref:`啟用除錯模式 <asyncio-debug-mode>`\\ 以取得任務建立處的追蹤資訊 "
443
434
"(traceback): ::"
444
435
445
- #: ../../library/asyncio-dev.rst:235
436
+ #: ../../library/asyncio-dev.rst:231
446
437
msgid "asyncio.run(main(), debug=True)"
447
438
msgstr "asyncio.run(main(), debug=True)"
448
439
449
- #: ../../library/asyncio-dev.rst:239
440
+ #: ../../library/asyncio-dev.rst:235
450
441
msgid ""
451
442
"Task exception was never retrieved\n"
452
443
"future: <Task finished coro=<bug() done, defined at test.py:3>\n"
@@ -477,3 +468,12 @@ msgstr ""
477
468
" File\" ../t.py\" , line 4, in bug\n"
478
469
" raise Exception(\" not consumed\" )\n"
479
470
"Exception: not consumed"
471
+
472
+ #~ msgid ""
473
+ #~ "asyncio checks for :ref:`coroutines that were not awaited <asyncio-"
474
+ #~ "coroutine-not-scheduled>` and logs them; this mitigates the \"forgotten "
475
+ #~ "await\" pitfall."
476
+ #~ msgstr ""
477
+ #~ "asyncio 會檢查\\ :ref:`未被等待的協程 <asyncio-coroutine-not-"
478
+ #~ "scheduled>`\\ 並記錄他們;這會減輕\"被遺忘的等待 (forgotten await)\" 問"
479
+ #~ "題。"