Expand Up @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.11\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date:2022-12-07 00:17 +0000\n" "POT-Creation-Date:2023-01-11 00:15 +0000\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-" Expand Down Expand Up @@ -145,47 +145,47 @@ msgstr "" msgid "On Windows, :class:`ProactorEventLoop` is now used by default." msgstr "" #: ../../library/asyncio-policy.rst:115 #: ../../library/asyncio-policy.rst:116 msgid "" ":meth:`get_event_loop` now emits a :exc:`DeprecationWarning` if there is no " "current event loop set and a new event loophas been implicitly created. In " "Python 3.12 it willbe an error." "In Python versions 3.10.9, 3.11.1 and 3.12 this function emits a :exc: " "`DeprecationWarning` if there is no running event loopand no current loop " "is set. In some future Python release this willbecome an error." msgstr "" #: ../../library/asyncio-policy.rst:123 #: ../../library/asyncio-policy.rst:124 msgid "" "An alternative event loop policy that uses the :class:`SelectorEventLoop` " "event loop implementation." msgstr "" #: ../../library/asyncio-policy.rst:126 ../../library/asyncio-policy.rst:134 #: ../../library/asyncio-policy.rst:127 ../../library/asyncio-policy.rst:135 msgid ":ref:`Availability <availability>`: Windows." msgstr ":ref:`適用 <availability>`:Windows。" #: ../../library/asyncio-policy.rst:131 #: ../../library/asyncio-policy.rst:132 msgid "" "An alternative event loop policy that uses the :class:`ProactorEventLoop` " "event loop implementation." msgstr "" #: ../../library/asyncio-policy.rst:140 #: ../../library/asyncio-policy.rst:141 msgid "Process Watchers" msgstr "" #: ../../library/asyncio-policy.rst:142 #: ../../library/asyncio-policy.rst:143 msgid "" "A process watcher allows customization of how an event loop monitors child " "processes on Unix. Specifically, the event loop needs to know when a child " "process has exited." msgstr "" #: ../../library/asyncio-policy.rst:146 #: ../../library/asyncio-policy.rst:147 msgid "" "In asyncio, child processes are created with :func:`create_subprocess_exec` " "and :meth:`loop.subprocess_exec` functions." msgstr "" #: ../../library/asyncio-policy.rst:150 #: ../../library/asyncio-policy.rst:151 msgid "" "asyncio defines the :class:`AbstractChildWatcher` abstract base class, which " "child watchers should implement, and has four different implementations: :" Expand All @@ -194,176 +194,176 @@ msgid "" "`FastChildWatcher`." msgstr "" #: ../../library/asyncio-policy.rst:156 #: ../../library/asyncio-policy.rst:157 msgid "" "See also the :ref:`Subprocess and Threads <asyncio-subprocess-threads>` " "section." msgstr "" #: ../../library/asyncio-policy.rst:159 #: ../../library/asyncio-policy.rst:160 msgid "" "The following two functions can be used to customize the child process " "watcher implementation used by the asyncio event loop:" msgstr "" #: ../../library/asyncio-policy.rst:164 #: ../../library/asyncio-policy.rst:165 msgid "Return the current child watcher for the current policy." msgstr "" #: ../../library/asyncio-policy.rst:168 #: ../../library/asyncio-policy.rst:169 msgid "" "Set the current child watcher to *watcher* for the current policy. " "*watcher* must implement methods defined in the :class:" "`AbstractChildWatcher` base class." msgstr "" #: ../../library/asyncio-policy.rst:173 #: ../../library/asyncio-policy.rst:174 msgid "" "Third-party event loops implementations might not support custom child " "watchers. For such event loops, using :func:`set_child_watcher` might be " "prohibited or have no effect." msgstr "" #: ../../library/asyncio-policy.rst:181 #: ../../library/asyncio-policy.rst:182 msgid "Register a new child handler." msgstr "" #: ../../library/asyncio-policy.rst:183 #: ../../library/asyncio-policy.rst:184 msgid "" "Arrange for ``callback(pid, returncode, *args)`` to be called when a process " "with PID equal to *pid* terminates. Specifying another callback for the " "same process replaces the previous handler." msgstr "" #: ../../library/asyncio-policy.rst:188 #: ../../library/asyncio-policy.rst:189 msgid "The *callback* callable must be thread-safe." msgstr "" #: ../../library/asyncio-policy.rst:192 #: ../../library/asyncio-policy.rst:193 msgid "Removes the handler for process with PID equal to *pid*." msgstr "" #: ../../library/asyncio-policy.rst:194 #: ../../library/asyncio-policy.rst:195 msgid "" "The function returns ``True`` if the handler was successfully removed, " "``False`` if there was nothing to remove." msgstr "" #: ../../library/asyncio-policy.rst:199 #: ../../library/asyncio-policy.rst:200 msgid "Attach the watcher to an event loop." msgstr "" #: ../../library/asyncio-policy.rst:201 #: ../../library/asyncio-policy.rst:202 msgid "" "If the watcher was previously attached to an event loop, then it is first " "detached before attaching to the new loop." msgstr "" #: ../../library/asyncio-policy.rst:204 #: ../../library/asyncio-policy.rst:205 msgid "Note: loop may be ``None``." msgstr "" #: ../../library/asyncio-policy.rst:208 #: ../../library/asyncio-policy.rst:209 msgid "Return ``True`` if the watcher is ready to use." msgstr "" #: ../../library/asyncio-policy.rst:210 #: ../../library/asyncio-policy.rst:211 msgid "" "Spawning a subprocess with *inactive* current child watcher raises :exc:" "`RuntimeError`." msgstr "" #: ../../library/asyncio-policy.rst:217 #: ../../library/asyncio-policy.rst:218 msgid "Close the watcher." msgstr "" #: ../../library/asyncio-policy.rst:219 #: ../../library/asyncio-policy.rst:220 msgid "" "This method has to be called to ensure that underlying resources are cleaned-" "up." msgstr "" #: ../../library/asyncio-policy.rst:224 #: ../../library/asyncio-policy.rst:225 msgid "" "This implementation starts a new waiting thread for every subprocess spawn." msgstr "" #: ../../library/asyncio-policy.rst:226 #: ../../library/asyncio-policy.rst:227 msgid "" "It works reliably even when the asyncio event loop is run in a non-main OS " "thread." msgstr "" #: ../../library/asyncio-policy.rst:228 #: ../../library/asyncio-policy.rst:229 msgid "" "There is no noticeable overhead when handling a big number of children " "(*O(1)* each time a child terminates), but starting a thread per process " "requires extra memory." msgstr "" #: ../../library/asyncio-policy.rst:231 #: ../../library/asyncio-policy.rst:232 msgid "This watcher is used by default." msgstr "" #: ../../library/asyncio-policy.rst:237 #: ../../library/asyncio-policy.rst:238 msgid "" "This implementation registers a :py:data:`SIGCHLD` signal handler on " "instantiation. That can break third-party code that installs a custom " "handler for :py:data:`SIGCHLD` signal." msgstr "" #: ../../library/asyncio-policy.rst:241 ../../library/asyncio-policy.rst:259 #: ../../library/asyncio-policy.rst:242 ../../library/asyncio-policy.rst:260 msgid "" "The watcher avoids disrupting other code spawning processes by polling every " "process explicitly on a :py:data:`SIGCHLD` signal." msgstr "" #: ../../library/asyncio-policy.rst:244 #: ../../library/asyncio-policy.rst:245 msgid "" "There is no limitation for running subprocesses from different threads once " "the watcher is installed." msgstr "" #: ../../library/asyncio-policy.rst:247 #: ../../library/asyncio-policy.rst:248 msgid "" "The solution is safe but it has a significant overhead when handling a big " "number of processes (*O(n)* each time a :py:data:`SIGCHLD` is received)." msgstr "" #: ../../library/asyncio-policy.rst:255 #: ../../library/asyncio-policy.rst:256 msgid "" "This implementation uses active event loop from the main thread to handle :" "py:data:`SIGCHLD` signal. If the main thread has no running event loop " "another thread cannot spawn a subprocess (:exc:`RuntimeError` is raised)." msgstr "" #: ../../library/asyncio-policy.rst:262 #: ../../library/asyncio-policy.rst:263 msgid "" "This solution is as safe as :class:`MultiLoopChildWatcher` and has the same " "*O(N)* complexity but requires a running event loop in the main thread to " "work." msgstr "" #: ../../library/asyncio-policy.rst:267 #: ../../library/asyncio-policy.rst:268 msgid "" "This implementation reaps every terminated processes by calling ``os." "waitpid(-1)`` directly, possibly breaking other code spawning processes and " "waiting for their termination." msgstr "" #: ../../library/asyncio-policy.rst:271 #: ../../library/asyncio-policy.rst:272 msgid "" "There is no noticeable overhead when handling a big number of children " "(*O(1)* each time a child terminates)." msgstr "" #: ../../library/asyncio-policy.rst:274 #: ../../library/asyncio-policy.rst:275 msgid "" "This solution requires a running event loop in the main thread to work, as :" "class:`SafeChildWatcher`." msgstr "" #: ../../library/asyncio-policy.rst:279 #: ../../library/asyncio-policy.rst:280 msgid "" "This implementation polls process file descriptors (pidfds) to await child " "process termination. In some respects, :class:`PidfdChildWatcher` is a " Expand All @@ -374,11 +374,11 @@ msgid "" "only work on recent (5.3+) kernels." msgstr "" #: ../../library/asyncio-policy.rst:293 #: ../../library/asyncio-policy.rst:294 msgid "Custom Policies" msgstr "" #: ../../library/asyncio-policy.rst:295 #: ../../library/asyncio-policy.rst:296 msgid "" "To implement a new event loop policy, it is recommended to subclass :class:" "`DefaultEventLoopPolicy` and override the methods for which custom behavior " Expand Down