@@ -838,22 +838,27 @@ msgid ""
838838"*finalizer* method see the implementation of "
839839"``asyncio.Loop.shutdown_asyncgens`` in :source:`Lib/asyncio/base_events.py`."
840840msgstr ""
841+ "为了能处理最终化,事件循环应该定义一个 *终结器* 函数,它接受一个异步生成器-迭代器且可能调用 :meth:`~agen.aclose` 并执行协程。"
842+ " 这个 *终结器* 可能通过调用 :func:`sys.set_asyncgen_hooks` 来注册。 当首次迭代时,异步生成器-"
843+ "迭代器将保存已注册的 *终结器* 以便在最终化时调用。 有关For a reference example of a *终结器* 方法的参考示例请查看 "
844+ ":source:`Lib/asyncio/base_events.py` 中实现的 "
845+ "``asyncio.Loop.shutdown_asyncgens``。"
841846
842847#: ../../reference/expressions.rst:662
843848msgid ""
844849"The expression ``yield from <expr>`` is a syntax error when used in an "
845850"asynchronous generator function."
846- msgstr ""
851+ msgstr "``yield from <expr>`` 表达式如果在异步生成器函数中使用会引发语法错误。 "
847852
848853#: ../../reference/expressions.rst:669
849854msgid "Asynchronous generator-iterator methods"
850- msgstr ""
855+ msgstr "异步生成器-迭代器方法 "
851856
852857#: ../../reference/expressions.rst:671
853858msgid ""
854859"This subsection describes the methods of an asynchronous generator iterator,"
855860" which are used to control the execution of a generator function."
856- msgstr ""
861+ msgstr "这个子小节描述了异步生成器迭代器的方法,它们可被用于控制生成器函数的执行。 "
857862
858863#: ../../reference/expressions.rst:679
859864msgid ""
@@ -868,11 +873,16 @@ msgid ""
868873"another value, the awaitable instead raises an :exc:`StopAsyncIteration` "
869874"exception, signalling that the asynchronous iteration has completed."
870875msgstr ""
876+ "返回一个可等待对象,它在运行时会开始执行该异步生成器或是从上次执行的 yield 表达式位置恢复执行。 当一个异步生成器函数通过 "
877+ ":meth:`~agen.__anext__` 方法恢复执行时,当前的 yield 表达式所返回的可等待对象总是取值为 "
878+ ":const:`None`,它在运行时将继续执行到下一个 yield 表达式。 该 yield 表达式的 "
879+ ":token:`expression_list` 的值会是完成的协程所引发的 :exc:`StopIteration` 异常的值。 "
880+ "如果异步生成器没有产生下一个值就退出,则该可等待对象将引发 :exc:`StopAsyncIteration` 异常,提示该异步迭代操作已完成。"
871881
872882#: ../../reference/expressions.rst:691
873883msgid ""
874884"This method is normally called implicitly by a :keyword:`async for` loop."
875- msgstr ""
885+ msgstr "此方法通常是通过 :keyword:`async for` 循环隐式地调用。 "
876886
877887#: ../../reference/expressions.rst:696
878888msgid ""
@@ -888,6 +898,11 @@ msgid ""
888898"called with :const:`None` as the argument, because there is no yield "
889899"expression that could receive the value."
890900msgstr ""
901+ "返回一个可等待对象,它在运行时会恢复该异步生成器的执行。 与生成器的 :meth:`~generator.send()` "
902+ "方法一样,此方法会“发送”一个值给异步生成器函数,其 *value* 参数会成为当前 yield 表达式的结果值。 :meth:`asend` "
903+ "方法所返回的可等待对象将返回生成器产生的下一个值,其值为所引发的 "
904+ ":exc:`StopIteration`,或者如果异步生成器没有产生下一个值就退出则引发 :exc:`StopAsyncIteration`。 当调用 "
905+ ":meth:`asend` 来启动异步生成器时,它必须以 :const:`None` 作为调用参数,因为这时没有可以接收值的 yield 表达式。"
891906
892907#: ../../reference/expressions.rst:711
893908msgid ""
@@ -900,6 +915,10 @@ msgid ""
900915"exception, or raises a different exception, then when the awaitable is run "
901916"that exception propagates to the caller of the awaitable."
902917msgstr ""
918+ "返回一个可等待对象,它会在异步生成器暂停的位置引发 ``type`` 类型的异常,并返回该生成器函数所产生的下一个值,其值为所引发的 "
919+ ":exc:`StopIteration` 异常。 如果异步生成器没有产生下一个值就退出,则将由该可等待对象引发 "
920+ ":exc:`StopAsyncIteration` 异常。 "
921+ "如果生成器函数没有捕获传入的异常,或引发了另一个异常,则当可等待对象运行时该异常会被传播给可等待对象的调用者。"
903922
904923#: ../../reference/expressions.rst:726
905924msgid ""
0 commit comments