@@ -22,7 +22,7 @@ msgid ""
22
22
msgstr ""
23
23
"Project-Id-Version : Python 3.13\n "
24
24
"Report-Msgid-Bugs-To : \n "
25
- "POT-Creation-Date : 2025-03-21 14:18+0000\n "
25
+ "POT-Creation-Date : 2025-04-18 14:18+0000\n "
26
26
"PO-Revision-Date : 2021-06-28 00:55+0000\n "
27
27
"Last-Translator : Freesand Leo <yuqinju@163.com>, 2025\n "
28
28
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -2193,12 +2193,18 @@ msgstr "请求取消 Task 对象。"
2193
2193
2194
2194
#: ../../library/asyncio-task.rst:1339
2195
2195
msgid ""
2196
- "This arranges for a :exc:`CancelledError` exception to be thrown into the "
2197
- "wrapped coroutine on the next cycle of the event loop ."
2198
- msgstr "这将安排在下一轮事件循环中抛出一个 :exc:`CancelledError` 异常给被封包的协程。 "
2196
+ "If the Task is already *done* or *cancelled*, return ``False``, otherwise, "
2197
+ "return ``True`` ."
2198
+ msgstr ""
2199
2199
2200
2200
#: ../../library/asyncio-task.rst:1342
2201
2201
msgid ""
2202
+ "The method arranges for a :exc:`CancelledError` exception to be thrown into "
2203
+ "the wrapped coroutine on the next cycle of the event loop."
2204
+ msgstr ""
2205
+
2206
+ #: ../../library/asyncio-task.rst:1345
2207
+ msgid ""
2202
2208
"The coroutine then has a chance to clean up or even deny the request by "
2203
2209
"suppressing the exception with a :keyword:`try` ... ... ``except "
2204
2210
"CancelledError`` ... :keyword:`finally` block. Therefore, unlike "
@@ -2213,22 +2219,22 @@ msgstr ""
2213
2219
":meth:`Task.cancel` 不保证 Task 会被取消,虽然完全抑制撤销并不常见也很不建议这样做。 "
2214
2220
"但是如果协程决定要抑制撤销,那么它需要额外调用 :meth:`Task.uncancel` 来捕获异常。"
2215
2221
2216
- #: ../../library/asyncio-task.rst:1352
2222
+ #: ../../library/asyncio-task.rst:1355
2217
2223
msgid "Added the *msg* parameter."
2218
2224
msgstr "增加了 *msg* 形参。"
2219
2225
2220
- #: ../../library/asyncio-task.rst:1355
2226
+ #: ../../library/asyncio-task.rst:1358
2221
2227
msgid ""
2222
2228
"The ``msg`` parameter is propagated from cancelled task to its awaiter."
2223
2229
msgstr "``msg`` 形参将从被取消的任务传播到其等待方。"
2224
2230
2225
- #: ../../library/asyncio-task.rst:1360
2231
+ #: ../../library/asyncio-task.rst:1363
2226
2232
msgid ""
2227
2233
"The following example illustrates how coroutines can intercept the "
2228
2234
"cancellation request::"
2229
2235
msgstr "以下示例演示了协程是如何侦听取消请求的::"
2230
2236
2231
- #: ../../library/asyncio-task.rst:1363
2237
+ #: ../../library/asyncio-task.rst:1366
2232
2238
msgid ""
2233
2239
"async def cancel_me():\n"
2234
2240
" print('cancel_me(): before sleep')\n"
@@ -2298,11 +2304,11 @@ msgstr ""
2298
2304
"# cancel_me(): after sleep\n"
2299
2305
"# main(): cancel_me is cancelled now"
2300
2306
2301
- #: ../../library/asyncio-task.rst:1399
2307
+ #: ../../library/asyncio-task.rst:1402
2302
2308
msgid "Return ``True`` if the Task is *cancelled*."
2303
2309
msgstr "如果 Task 对象 *被取消* 则返回 ``True``。"
2304
2310
2305
- #: ../../library/asyncio-task.rst:1401
2311
+ #: ../../library/asyncio-task.rst:1404
2306
2312
msgid ""
2307
2313
"The Task is *cancelled* when the cancellation was requested with "
2308
2314
":meth:`cancel` and the wrapped coroutine propagated the "
@@ -2311,21 +2317,21 @@ msgstr ""
2311
2317
"当使用 :meth:`cancel` 发出取消请求时 Task 会被 *取消*,其封包的协程将传播被抛入的 :exc:`CancelledError` "
2312
2318
"异常。"
2313
2319
2314
- #: ../../library/asyncio-task.rst:1407
2320
+ #: ../../library/asyncio-task.rst:1410
2315
2321
msgid "Decrement the count of cancellation requests to this Task."
2316
2322
msgstr "递减对此任务的取消请求计数。"
2317
2323
2318
- #: ../../library/asyncio-task.rst:1409
2324
+ #: ../../library/asyncio-task.rst:1412
2319
2325
msgid "Returns the remaining number of cancellation requests."
2320
2326
msgstr "返回剩余的取消请求数量。"
2321
2327
2322
- #: ../../library/asyncio-task.rst:1411
2328
+ #: ../../library/asyncio-task.rst:1414
2323
2329
msgid ""
2324
2330
"Note that once execution of a cancelled task completed, further calls to "
2325
2331
":meth:`uncancel` are ineffective."
2326
2332
msgstr "请注意一旦被取消的任务执行完成,继续调用 :meth:`uncancel` 将是低效的。"
2327
2333
2328
- #: ../../library/asyncio-task.rst:1416
2334
+ #: ../../library/asyncio-task.rst:1419
2329
2335
msgid ""
2330
2336
"This method is used by asyncio's internals and isn't expected to be used by "
2331
2337
"end-user code. In particular, if a Task gets successfully uncancelled, this"
@@ -2336,7 +2342,7 @@ msgstr ""
2336
2342
"此方法是供 asyncio 内部使用而不应被最终用户代码所使用。 特别地,在一个 Task 成功地保持未取消状态的时候使用,这可以允许结构化的并发元素如"
2337
2343
" :ref:`taskgroups` 和 :func:`asyncio.timeout` 继续运行,将取消操作隔离在相应的结构化代码块中。 例如::"
2338
2344
2339
- #: ../../library/asyncio-task.rst:1423
2345
+ #: ../../library/asyncio-task.rst:1426
2340
2346
msgid ""
2341
2347
"async def make_request_with_timeout():\n"
2342
2348
" try:\n"
@@ -2360,7 +2366,7 @@ msgstr ""
2360
2366
" # 不受超时影响的外层代码:\n"
2361
2367
" await unrelated_code()"
2362
2368
2363
- #: ../../library/asyncio-task.rst:1434
2369
+ #: ../../library/asyncio-task.rst:1437
2364
2370
msgid ""
2365
2371
"While the block with ``make_request()`` and ``make_another_request()`` might"
2366
2372
" get cancelled due to the timeout, ``unrelated_code()`` should continue "
@@ -2372,14 +2378,14 @@ msgstr ""
2372
2378
"``unrelated_code()`` 应当在超时的情况下继续运行。 这是通过 :meth:`uncancel` 实现的。 "
2373
2379
":class:`TaskGroup` 上下文管理器也会以类似的方式来使用 :func:`uncancel`。"
2374
2380
2375
- #: ../../library/asyncio-task.rst:1440
2381
+ #: ../../library/asyncio-task.rst:1443
2376
2382
msgid ""
2377
2383
"If end-user code is, for some reason, suppressing cancellation by catching "
2378
2384
":exc:`CancelledError`, it needs to call this method to remove the "
2379
2385
"cancellation state."
2380
2386
msgstr "如果最终用户代码出于某种原因通过捕获 :exc:`CancelledError` 抑制撤销操作,那么它需要调用此方法来移除撤销状态。"
2381
2387
2382
- #: ../../library/asyncio-task.rst:1444
2388
+ #: ../../library/asyncio-task.rst:1447
2383
2389
msgid ""
2384
2390
"When this method decrements the cancellation count to zero, the method "
2385
2391
"checks if a previous :meth:`cancel` call had arranged for "
@@ -2390,17 +2396,17 @@ msgstr ""
2390
2396
"当该方法将取消计数递减至零,该方法会检查之前的 :meth:`cancel` 调用是否已安排将 :exc:`CancelledError` "
2391
2397
"抛出到任务中。 如果尚未抛出,则该安排将被撤销(通过重置内部的 ``_must_cancel`` 旗标 )。"
2392
2398
2393
- #: ../../library/asyncio-task.rst:1450
2399
+ #: ../../library/asyncio-task.rst:1453
2394
2400
msgid "Changed to rescind pending cancellation requests upon reaching zero."
2395
2401
msgstr "更改为在到达零值时撤回待处理的取消请求。"
2396
2402
2397
- #: ../../library/asyncio-task.rst:1455
2403
+ #: ../../library/asyncio-task.rst:1458
2398
2404
msgid ""
2399
2405
"Return the number of pending cancellation requests to this Task, i.e., the "
2400
2406
"number of calls to :meth:`cancel` less the number of :meth:`uncancel` calls."
2401
2407
msgstr "返回对此 Task 的挂起请求次数,即对 :meth:`cancel` 的调用次数减去 :meth:`uncancel` 的调用次数。"
2402
2408
2403
- #: ../../library/asyncio-task.rst:1459
2409
+ #: ../../library/asyncio-task.rst:1462
2404
2410
msgid ""
2405
2411
"Note that if this number is greater than zero but the Task is still "
2406
2412
"executing, :meth:`cancelled` will still return ``False``. This is because "
@@ -2411,7 +2417,7 @@ msgstr ""
2411
2417
"请注意如果该数字大于零但相应 Task 仍在执行,:meth:`cancelled` 仍将返回 ``False``。 这是因此该数字可通过调用 "
2412
2418
":meth:`uncancel` 来减少,这会导致任务在取消请求降到零时尚未被取消。"
2413
2419
2414
- #: ../../library/asyncio-task.rst:1465
2420
+ #: ../../library/asyncio-task.rst:1468
2415
2421
msgid ""
2416
2422
"This method is used by asyncio's internals and isn't expected to be used by "
2417
2423
"end-user code. See :meth:`uncancel` for more details."
0 commit comments