From 8516262ee9fe39cc105042d08fbd384f6b8ecc4e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 11 Apr 2026 16:08:03 +0000 Subject: [PATCH 1/3] sync with cpython 620fb743 --- library/sys.monitoring.po | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/sys.monitoring.po b/library/sys.monitoring.po index 3d4525d952b..5af1c69f1e5 100644 --- a/library/sys.monitoring.po +++ b/library/sys.monitoring.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-04-11 16:06+0000\n" "PO-Revision-Date: 2025-11-07 17:51+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,10 +21,12 @@ msgid ":mod:`!sys.monitoring` --- Execution event monitoring" msgstr ":mod:`!sys.monitoring` --- 執行事件監控" #: ../../library/sys.monitoring.rst:13 +#, fuzzy msgid "" ":mod:`!sys.monitoring` is a namespace within the :mod:`sys` module, not an " -"independent module, so there is no need to ``import sys.monitoring``, simply " -"``import sys`` and then use ``sys.monitoring``." +"independent module, and ``import sys.monitoring`` would fail with a :exc:" +"`ModuleNotFoundError`. Instead, simply ``import sys`` and then use ``sys." +"monitoring``." msgstr "" ":mod:`!sys.monitoring` 是 :mod:`sys` 模組內的一個命名空間,不是一個獨立的模" "組,所以不需要 ``import sys.monitoring``,只需 ``import sys`` 然後使用 ``sys." From 5ea3e3a1dc7cc3c7890b4c9698a0ef8516642123 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 12 Apr 2026 00:26:50 +0000 Subject: [PATCH 2/3] sync with cpython 47b916e2 --- c-api/dict.po | 233 ++++++++++++++++++++------------- c-api/set.po | 84 +++++++----- library/importlib.resources.po | 133 ++++++++++--------- 3 files changed, 267 insertions(+), 183 deletions(-) diff --git a/c-api/dict.po b/c-api/dict.po index e23ff151870..19edbd8f092 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-12-02 00:15+0000\n" +"POT-Creation-Date: 2026-04-12 00:25+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -84,18 +84,26 @@ msgid "" "is equivalent to the Python expression ``key in p``." msgstr "" -#: ../../c-api/dict.rst:71 +#: ../../c-api/dict.rst:70 ../../c-api/dict.rst:97 ../../c-api/dict.rst:117 +#: ../../c-api/dict.rst:140 ../../c-api/dict.rst:257 ../../c-api/dict.rst:279 +msgid "" +"The operation is atomic on :term:`free threading ` when " +"*key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:" +"`bytes`." +msgstr "" + +#: ../../c-api/dict.rst:76 msgid "" "This is the same as :c:func:`PyDict_Contains`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:80 +#: ../../c-api/dict.rst:85 msgid "Return a new dictionary that contains the same key-value pairs as *p*." msgstr "回傳一個新的字典,包含與 *p* 相同的鍵值對。" -#: ../../c-api/dict.rst:85 +#: ../../c-api/dict.rst:90 msgid "" "Insert *val* into the dictionary *p* with a key of *key*. *key* must be :" "term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return ``0`` " @@ -103,14 +111,14 @@ msgid "" "to *val*." msgstr "" -#: ../../c-api/dict.rst:93 +#: ../../c-api/dict.rst:103 msgid "" "This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:100 +#: ../../c-api/dict.rst:110 msgid "" "Remove the entry in dictionary *p* with key *key*. *key* must be :term:" "`hashable`; if it isn't, :exc:`TypeError` is raised. If *key* is not in the " @@ -118,72 +126,79 @@ msgid "" "failure." msgstr "" -#: ../../c-api/dict.rst:108 +#: ../../c-api/dict.rst:123 msgid "" "This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:115 +#: ../../c-api/dict.rst:130 msgid "" "Return a new :term:`strong reference` to the object from dictionary *p* " "which has a key *key*:" msgstr "" -#: ../../c-api/dict.rst:118 +#: ../../c-api/dict.rst:133 msgid "" "If the key is present, set *\\*result* to a new :term:`strong reference` to " "the value and return ``1``." msgstr "" -#: ../../c-api/dict.rst:120 +#: ../../c-api/dict.rst:135 msgid "If the key is missing, set *\\*result* to ``NULL`` and return ``0``." msgstr "如果鍵不存在,將 *\\*result* 設為 ``NULL`` 並回傳 ``0``。" -#: ../../c-api/dict.rst:121 ../../c-api/dict.rst:218 +#: ../../c-api/dict.rst:136 ../../c-api/dict.rst:272 msgid "On error, raise an exception and return ``-1``." msgstr "錯誤發生時,引發一個例外並回傳 ``-1``。" -#: ../../c-api/dict.rst:125 +#: ../../c-api/dict.rst:145 msgid "See also the :c:func:`PyObject_GetItem` function." msgstr "另見 :c:func:`PyObject_GetItem` 函式。" -#: ../../c-api/dict.rst:130 +#: ../../c-api/dict.rst:150 msgid "" "Return a :term:`borrowed reference` to the object from dictionary *p* which " "has a key *key*. Return ``NULL`` if the key *key* is missing *without* " "setting an exception." msgstr "" -#: ../../c-api/dict.rst:136 +#: ../../c-api/dict.rst:156 msgid "" "Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" "`~object.__eq__` methods are silently ignored. Prefer the :c:func:" "`PyDict_GetItemWithError` function instead." msgstr "" -#: ../../c-api/dict.rst:140 +#: ../../c-api/dict.rst:162 ../../c-api/dict.rst:181 +msgid "" +"In the :term:`free-threaded build`, the returned :term:`borrowed reference` " +"may become invalid if another thread modifies the dictionary concurrently. " +"Prefer :c:func:`PyDict_GetItemRef`, which returns a :term:`strong reference`." +msgstr "" + +#: ../../c-api/dict.rst:167 msgid "" "Calling this API without an :term:`attached thread state` had been allowed " "for historical reason. It is no longer allowed." msgstr "" -#: ../../c-api/dict.rst:147 +#: ../../c-api/dict.rst:174 msgid "" "Variant of :c:func:`PyDict_GetItem` that does not suppress exceptions. " "Return ``NULL`` **with** an exception set if an exception occurred. Return " "``NULL`` **without** an exception set if the key wasn't present." msgstr "" -#: ../../c-api/dict.rst:155 +#: ../../c-api/dict.rst:189 msgid "" "This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:161 +#: ../../c-api/dict.rst:195 msgid "" "Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" "`~object.__eq__` methods or while creating the temporary :class:`str` object " @@ -191,13 +206,21 @@ msgid "" "function with your own :c:func:`PyUnicode_FromString` *key* instead." msgstr "" -#: ../../c-api/dict.rst:170 +#: ../../c-api/dict.rst:203 +msgid "" +"In the :term:`free-threaded build`, the returned :term:`borrowed reference` " +"may become invalid if another thread modifies the dictionary concurrently. " +"Prefer :c:func:`PyDict_GetItemStringRef`, which returns a :term:`strong " +"reference`." +msgstr "" + +#: ../../c-api/dict.rst:211 msgid "" "Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as a :c:expr:" "`const char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:179 +#: ../../c-api/dict.rst:220 msgid "" "This is the same as the Python-level :meth:`dict.setdefault`. If present, " "it returns the value corresponding to *key* from the dictionary *p*. If the " @@ -207,7 +230,15 @@ msgid "" "the insertion." msgstr "" -#: ../../c-api/dict.rst:190 +#: ../../c-api/dict.rst:230 +msgid "" +"In the :term:`free-threaded build`, the returned :term:`borrowed reference` " +"may become invalid if another thread modifies the dictionary concurrently. " +"Prefer :c:func:`PyDict_SetDefaultRef`, which returns a :term:`strong " +"reference`." +msgstr "" + +#: ../../c-api/dict.rst:239 msgid "" "Inserts *default_value* into the dictionary *p* with a key of *key* if the " "key is not already present in the dictionary. If *result* is not ``NULL``, " @@ -219,7 +250,7 @@ msgid "" "exception, and sets ``*result`` to ``NULL``." msgstr "" -#: ../../c-api/dict.rst:200 +#: ../../c-api/dict.rst:249 msgid "" "For clarity: if you have a strong reference to *default_value* before " "calling this function, then after it returns, you hold a strong reference to " @@ -227,63 +258,63 @@ msgid "" "to the same object: in that case you hold two separate references to it." msgstr "" -#: ../../c-api/dict.rst:211 +#: ../../c-api/dict.rst:265 msgid "" "Remove *key* from dictionary *p* and optionally return the removed value. Do " "not raise :exc:`KeyError` if the key is missing." msgstr "" -#: ../../c-api/dict.rst:214 +#: ../../c-api/dict.rst:268 msgid "" "If the key is present, set *\\*result* to a new reference to the removed " "value if *result* is not ``NULL``, and return ``1``." msgstr "" -#: ../../c-api/dict.rst:216 +#: ../../c-api/dict.rst:270 msgid "" "If the key is missing, set *\\*result* to ``NULL`` if *result* is not " "``NULL``, and return ``0``." msgstr "" -#: ../../c-api/dict.rst:220 +#: ../../c-api/dict.rst:274 msgid "" "Similar to :meth:`dict.pop`, but without the default value and not raising :" "exc:`KeyError` if the key is missing." msgstr "" -#: ../../c-api/dict.rst:228 +#: ../../c-api/dict.rst:287 msgid "" "Similar to :c:func:`PyDict_Pop`, but *key* is specified as a :c:expr:`const " "char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:237 +#: ../../c-api/dict.rst:296 msgid "" "Return a :c:type:`PyListObject` containing all the items from the dictionary." msgstr "回傳一個包含字典中所有項目的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:242 +#: ../../c-api/dict.rst:301 msgid "" "Return a :c:type:`PyListObject` containing all the keys from the dictionary." msgstr "回傳一個包含字典中所有鍵的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:247 +#: ../../c-api/dict.rst:306 msgid "" "Return a :c:type:`PyListObject` containing all the values from the " "dictionary *p*." msgstr "回傳一個包含字典 *p* 中所有值的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:255 +#: ../../c-api/dict.rst:314 msgid "" "Return the number of items in the dictionary. This is equivalent to " "``len(p)`` on a dictionary." msgstr "回傳字典中項目的數量。此與於字典呼叫 ``len(p)`` 等效。" -#: ../../c-api/dict.rst:261 +#: ../../c-api/dict.rst:320 msgid "Similar to :c:func:`PyDict_Size`, but without error checking." msgstr "和 :c:func:`PyDict_Size` 類似,但沒有錯誤檢查。" -#: ../../c-api/dict.rst:266 +#: ../../c-api/dict.rst:325 msgid "" "Iterate over all key-value pairs in the dictionary *p*. The :c:type:" "`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` prior to the " @@ -297,11 +328,11 @@ msgid "" "structure is sparse, the offsets are not consecutive." msgstr "" -#: ../../c-api/dict.rst:277 +#: ../../c-api/dict.rst:336 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/dict.rst:279 +#: ../../c-api/dict.rst:338 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -319,14 +350,14 @@ msgstr "" " ...\n" "}" -#: ../../c-api/dict.rst:287 +#: ../../c-api/dict.rst:346 msgid "" "The dictionary *p* should not be mutated during iteration. It is safe to " "modify the values of the keys as you iterate over the dictionary, but only " "so long as the set of keys does not change. For example::" msgstr "" -#: ../../c-api/dict.rst:291 +#: ../../c-api/dict.rst:350 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -364,14 +395,14 @@ msgstr "" " Py_DECREF(o);\n" "}" -#: ../../c-api/dict.rst:309 +#: ../../c-api/dict.rst:368 msgid "" "The function is not thread-safe in the :term:`free-threaded ` build without external synchronization. You can use :c:macro:" "`Py_BEGIN_CRITICAL_SECTION` to lock the dictionary while iterating over it::" msgstr "" -#: ../../c-api/dict.rst:314 +#: ../../c-api/dict.rst:373 msgid "" "Py_BEGIN_CRITICAL_SECTION(self->dict);\n" "while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" @@ -385,7 +416,7 @@ msgstr "" "}\n" "Py_END_CRITICAL_SECTION();" -#: ../../c-api/dict.rst:322 +#: ../../c-api/dict.rst:381 msgid "" "On the free-threaded build, this function can be used safely inside a " "critical section. However, the references returned for *pkey* and *pvalue* " @@ -396,7 +427,7 @@ msgid "" "`Py_NewRef`)." msgstr "" -#: ../../c-api/dict.rst:332 +#: ../../c-api/dict.rst:391 msgid "" "Iterate over mapping object *b* adding key-value pairs to dictionary *a*. " "*b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys` " @@ -406,7 +437,15 @@ msgid "" "or ``-1`` if an exception was raised." msgstr "" -#: ../../c-api/dict.rst:342 +#: ../../c-api/dict.rst:400 ../../c-api/dict.rst:416 +msgid "" +"In the :term:`free-threaded build`, when *b* is a :class:`dict` (with the " +"standard iterator), both *a* and *b* are locked for the duration of the " +"operation. When *b* is a non-dict mapping, only *a* is locked; *b* may be " +"concurrently modified by another thread." +msgstr "" + +#: ../../c-api/dict.rst:408 msgid "" "This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to ``a." "update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall back " @@ -415,7 +454,7 @@ msgid "" "exception was raised." msgstr "" -#: ../../c-api/dict.rst:351 +#: ../../c-api/dict.rst:424 msgid "" "Update or merge into dictionary *a*, from the key-value pairs in *seq2*. " "*seq2* must be an iterable object producing iterable objects of length 2, " @@ -424,7 +463,7 @@ msgid "" "if an exception was raised. Equivalent Python (except for the return value)::" msgstr "" -#: ../../c-api/dict.rst:358 +#: ../../c-api/dict.rst:431 msgid "" "def PyDict_MergeFromSeq2(a, seq2, override):\n" " for key, value in seq2:\n" @@ -436,7 +475,14 @@ msgstr "" " if override or key not in a:\n" " a[key] = value" -#: ../../c-api/dict.rst:365 +#: ../../c-api/dict.rst:438 +msgid "" +"In the :term:`free-threaded ` build, only *a* is locked. The " +"iteration over *seq2* is not synchronized; *seq2* may be concurrently " +"modified by another thread." +msgstr "" + +#: ../../c-api/dict.rst:445 msgid "" "Register *callback* as a dictionary watcher. Return a non-negative integer " "id which must be passed to future calls to :c:func:`PyDict_Watch`. In case " @@ -444,21 +490,28 @@ msgid "" "exception." msgstr "" -#: ../../c-api/dict.rst:374 +#: ../../c-api/dict.rst:452 ../../c-api/dict.rst:467 +msgid "" +"This function is not internally synchronized. In the :term:`free-threaded " +"` build, callers should ensure no concurrent calls to :c:" +"func:`PyDict_AddWatcher` or :c:func:`PyDict_ClearWatcher` are in progress." +msgstr "" + +#: ../../c-api/dict.rst:461 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g. if the " "given *watcher_id* was never registered.)" msgstr "" -#: ../../c-api/dict.rst:382 +#: ../../c-api/dict.rst:476 msgid "" "Mark dictionary *dict* as watched. The callback granted *watcher_id* by :c:" "func:`PyDict_AddWatcher` will be called when *dict* is modified or " "deallocated. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:390 +#: ../../c-api/dict.rst:484 msgid "" "Mark dictionary *dict* as no longer watched. The callback granted " "*watcher_id* by :c:func:`PyDict_AddWatcher` will no longer be called when " @@ -466,7 +519,7 @@ msgid "" "watched by this watcher. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:399 +#: ../../c-api/dict.rst:493 msgid "" "Enumeration of possible dictionary watcher events: ``PyDict_EVENT_ADDED``, " "``PyDict_EVENT_MODIFIED``, ``PyDict_EVENT_DELETED``, " @@ -474,11 +527,11 @@ msgid "" "``PyDict_EVENT_DEALLOCATED``." msgstr "" -#: ../../c-api/dict.rst:407 +#: ../../c-api/dict.rst:501 msgid "Type of a dict watcher callback function." msgstr "" -#: ../../c-api/dict.rst:409 +#: ../../c-api/dict.rst:503 msgid "" "If *event* is ``PyDict_EVENT_CLEARED`` or ``PyDict_EVENT_DEALLOCATED``, both " "*key* and *new_value* will be ``NULL``. If *event* is ``PyDict_EVENT_ADDED`` " @@ -487,7 +540,7 @@ msgid "" "dictionary and *new_value* will be ``NULL``." msgstr "" -#: ../../c-api/dict.rst:415 +#: ../../c-api/dict.rst:509 msgid "" "``PyDict_EVENT_CLONED`` occurs when *dict* was previously empty and another " "dict is merged into it. To maintain efficiency of this operation, per-key " @@ -495,14 +548,14 @@ msgid "" "``PyDict_EVENT_CLONED`` is issued, and *key* will be the source dictionary." msgstr "" -#: ../../c-api/dict.rst:421 +#: ../../c-api/dict.rst:515 msgid "" "The callback may inspect but must not modify *dict*; doing so could have " "unpredictable effects, including infinite recursion. Do not trigger Python " "code execution in the callback, as it could modify the dict as a side effect." msgstr "" -#: ../../c-api/dict.rst:425 +#: ../../c-api/dict.rst:519 msgid "" "If *event* is ``PyDict_EVENT_DEALLOCATED``, taking a new reference in the " "callback to the about-to-be-destroyed dictionary will resurrect it and " @@ -511,20 +564,20 @@ msgid "" "again." msgstr "" -#: ../../c-api/dict.rst:431 +#: ../../c-api/dict.rst:525 msgid "" "Callbacks occur before the notified modification to *dict* takes place, so " "the prior state of *dict* can be inspected." msgstr "" -#: ../../c-api/dict.rst:434 +#: ../../c-api/dict.rst:528 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/dict.rst:438 +#: ../../c-api/dict.rst:532 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -533,11 +586,11 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/dict.rst:448 +#: ../../c-api/dict.rst:542 msgid "Dictionary View Objects" msgstr "字典視圖物件" -#: ../../c-api/dict.rst:452 +#: ../../c-api/dict.rst:546 msgid "" "Return true if *op* is a view of a set inside a dictionary. This is " "currently equivalent to :c:expr:`PyDictKeys_Check(op) || " @@ -546,55 +599,55 @@ msgstr "" "若 *op* 是一個字典中集合的視圖則會回傳 true。這目前等同於 :c:expr:" "`PyDictKeys_Check(op) || PyDictItems_Check(op)`。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:459 +#: ../../c-api/dict.rst:553 msgid "" "Type object for a view of dictionary keys. In Python, this is the type of " "the object returned by :meth:`dict.keys`." msgstr "" -#: ../../c-api/dict.rst:465 +#: ../../c-api/dict.rst:559 msgid "" "Return true if *op* is an instance of a dictionary keys view. This function " "always succeeds." msgstr "若 *op* 是一個字典鍵視圖的實例則會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:471 +#: ../../c-api/dict.rst:565 msgid "" "Type object for a view of dictionary values. In Python, this is the type of " "the object returned by :meth:`dict.values`." msgstr "" -#: ../../c-api/dict.rst:477 +#: ../../c-api/dict.rst:571 msgid "" "Return true if *op* is an instance of a dictionary values view. This " "function always succeeds." msgstr "若 *op* 是一個字典值視圖的實例則會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:483 +#: ../../c-api/dict.rst:577 msgid "" "Type object for a view of dictionary items. In Python, this is the type of " "the object returned by :meth:`dict.items`." msgstr "" -#: ../../c-api/dict.rst:489 +#: ../../c-api/dict.rst:583 msgid "" "Return true if *op* is an instance of a dictionary items view. This function " "always succeeds." msgstr "" "若 *op* 是一個字典項目視圖的實例則會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:494 +#: ../../c-api/dict.rst:588 msgid "Ordered Dictionaries" msgstr "有序字典" -#: ../../c-api/dict.rst:496 +#: ../../c-api/dict.rst:590 msgid "" "Python's C API provides interface for :class:`collections.OrderedDict` from " "C. Since Python 3.7, dictionaries are ordered by default, so there is " "usually little need for these functions; prefer ``PyDict*`` where possible." msgstr "" -#: ../../c-api/dict.rst:503 +#: ../../c-api/dict.rst:597 msgid "" "Type object for ordered dictionaries. This is the same object as :class:" "`collections.OrderedDict` in the Python layer." @@ -602,7 +655,7 @@ msgstr "" "有序字典的型別物件。此與 Python 層中的 :class:`collections.OrderedDict` 為同" "一個物件。" -#: ../../c-api/dict.rst:509 +#: ../../c-api/dict.rst:603 msgid "" "Return true if *od* is an ordered dictionary object or an instance of a " "subtype of the :class:`~collections.OrderedDict` type. This function always " @@ -611,7 +664,7 @@ msgstr "" "若 *od* 是一個有序字典物件或 :class:`~collections.OrderedDict` 的子型別實例則" "會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:516 +#: ../../c-api/dict.rst:610 msgid "" "Return true if *od* is an ordered dictionary object, but not an instance of " "a subtype of the :class:`~collections.OrderedDict` type. This function " @@ -620,79 +673,79 @@ msgstr "" "若 *od* 是一個有序字典物件但並不是一個 :class:`~collections.OrderedDict` 子型" "別的實例,則回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:523 +#: ../../c-api/dict.rst:617 msgid "Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries." msgstr "" -#: ../../c-api/dict.rst:528 +#: ../../c-api/dict.rst:622 msgid "Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries." msgstr "" -#: ../../c-api/dict.rst:533 +#: ../../c-api/dict.rst:627 msgid "Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries." msgstr "" -#: ../../c-api/dict.rst:538 +#: ../../c-api/dict.rst:632 msgid "Return a new empty ordered dictionary, or ``NULL`` on failure." msgstr "回傳一個新的空有序字典,或在失敗時回傳 ``NULL``。" -#: ../../c-api/dict.rst:540 +#: ../../c-api/dict.rst:634 msgid "This is analogous to :c:func:`PyDict_New`." msgstr "這和 :c:func:`PyDict_New` 類似。" -#: ../../c-api/dict.rst:545 +#: ../../c-api/dict.rst:639 msgid "" "Insert *value* into the ordered dictionary *od* with a key of *key*. Return " "``0`` on success or ``-1`` with an exception set on failure." msgstr "" -#: ../../c-api/dict.rst:548 +#: ../../c-api/dict.rst:642 msgid "This is analogous to :c:func:`PyDict_SetItem`." msgstr "這和 :c:func:`PyDict_SetItem` 類似。" -#: ../../c-api/dict.rst:553 +#: ../../c-api/dict.rst:647 msgid "" "Remove the entry in the ordered dictionary *od* with key *key*. Return ``0`` " "on success or ``-1`` with an exception set on failure." msgstr "" -#: ../../c-api/dict.rst:556 +#: ../../c-api/dict.rst:650 msgid "This is analogous to :c:func:`PyDict_DelItem`." msgstr "這和 :c:func:`PyDict_DelItem` 類似。" -#: ../../c-api/dict.rst:559 +#: ../../c-api/dict.rst:653 msgid "These are :term:`soft deprecated` aliases to ``PyDict`` APIs:" msgstr "" -#: ../../c-api/dict.rst:566 +#: ../../c-api/dict.rst:660 msgid "``PyODict``" msgstr "``PyODict``" -#: ../../c-api/dict.rst:567 +#: ../../c-api/dict.rst:661 msgid "``PyDict``" msgstr "``PyDict``" -#: ../../c-api/dict.rst:569 +#: ../../c-api/dict.rst:663 msgid ":c:func:`PyDict_GetItem`" msgstr ":c:func:`PyDict_GetItem`" -#: ../../c-api/dict.rst:571 +#: ../../c-api/dict.rst:665 msgid ":c:func:`PyDict_GetItemWithError`" msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../c-api/dict.rst:573 +#: ../../c-api/dict.rst:667 msgid ":c:func:`PyDict_GetItemString`" msgstr ":c:func:`PyDict_GetItemString`" -#: ../../c-api/dict.rst:575 +#: ../../c-api/dict.rst:669 msgid ":c:func:`PyDict_Contains`" msgstr ":c:func:`PyDict_Contains`" -#: ../../c-api/dict.rst:577 +#: ../../c-api/dict.rst:671 msgid ":c:func:`PyDict_Size`" msgstr ":c:func:`PyDict_Size`" -#: ../../c-api/dict.rst:579 +#: ../../c-api/dict.rst:673 msgid ":c:func:`PyDict_GET_SIZE`" msgstr ":c:func:`PyDict_GET_SIZE`" @@ -704,10 +757,10 @@ msgstr "object(物件)" msgid "dictionary" msgstr "dictionary(字典)" -#: ../../c-api/dict.rst:253 +#: ../../c-api/dict.rst:312 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/dict.rst:253 +#: ../../c-api/dict.rst:312 msgid "len" msgstr "len" diff --git a/c-api/set.po b/c-api/set.po index 4225d058692..fe69922ab0d 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-15 00:15+0000\n" +"POT-Creation-Date: 2026-04-12 00:25+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -70,44 +70,48 @@ msgid "" "Return true if *p* is a :class:`set` object or an instance of a subtype. " "This function always succeeds." msgstr "" -"如果 *p* 是 :class:`set` 物件或是子類別的實例,則回傳 true。此函式總會成功執行。" +"如果 *p* 是 :class:`set` 物件或是子類別的實例,則回傳 true。此函式總會成功執" +"行。" #: ../../c-api/set.rst:60 msgid "" "Return true if *p* is a :class:`frozenset` object or an instance of a " "subtype. This function always succeeds." msgstr "" -"如果 *p* 是 :class:`frozenset` 物件或是子類別的實例,則回傳 true。此函式總會成功執行。" +"如果 *p* 是 :class:`frozenset` 物件或是子類別的實例,則回傳 true。此函式總會" +"成功執行。" #: ../../c-api/set.rst:65 msgid "" "Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or " "an instance of a subtype. This function always succeeds." msgstr "" -"如果 *p* 是 :class:`set` 物件、:class:`frozenset` 物件,或是子類別的實例,則回傳 true。" -"此函式總會成功執行。" +"如果 *p* 是 :class:`set` 物件、:class:`frozenset` 物件,或是子類別的實例,則" +"回傳 true。此函式總會成功執行。" #: ../../c-api/set.rst:70 msgid "" "Return true if *p* is a :class:`set` object but not an instance of a " "subtype. This function always succeeds." msgstr "" -"如果 *p* 是 :class:`set` 物件但不是子類別的實例,則回傳 true。此函式總會成功執行。" +"如果 *p* 是 :class:`set` 物件但不是子類別的實例,則回傳 true。此函式總會成功" +"執行。" #: ../../c-api/set.rst:77 msgid "" "Return true if *p* is a :class:`set` object or a :class:`frozenset` object " "but not an instance of a subtype. This function always succeeds." msgstr "" -"如果 *p* 是 :class:`set` 物件或 :class:`frozenset` 物件但不是子類別的實例,則回傳 " -"true。此函式總會成功執行。" +"如果 *p* 是 :class:`set` 物件或 :class:`frozenset` 物件但不是子類別的實例,則" +"回傳 true。此函式總會成功執行。" #: ../../c-api/set.rst:83 msgid "" "Return true if *p* is a :class:`frozenset` object but not an instance of a " "subtype. This function always succeeds." msgstr "" -"如果 *p* 是 :class:`frozenset` 物件但不是子類別的實例,則回傳 true。此函式總會成功執行。" +"如果 *p* 是 :class:`frozenset` 物件但不是子類別的實例,則回傳 true。此函式總" +"會成功執行。" #: ../../c-api/set.rst:89 msgid "" @@ -118,7 +122,13 @@ msgid "" "(``c=set(s)``)." msgstr "" -#: ../../c-api/set.rst:98 +#: ../../c-api/set.rst:97 ../../c-api/set.rst:110 +msgid "" +"The operation is atomic on :term:`free threading ` when " +"*iterable* is a :class:`set`, :class:`frozenset` or :class:`dict`." +msgstr "" + +#: ../../c-api/set.rst:103 msgid "" "Return a new :class:`frozenset` containing objects returned by the " "*iterable*. The *iterable* may be ``NULL`` to create a new empty frozenset. " @@ -126,24 +136,24 @@ msgid "" "`TypeError` if *iterable* is not actually iterable." msgstr "" -#: ../../c-api/set.rst:104 +#: ../../c-api/set.rst:114 msgid "" "The following functions and macros are available for instances of :class:" "`set` or :class:`frozenset` or instances of their subtypes." msgstr "" -#: ../../c-api/set.rst:112 +#: ../../c-api/set.rst:122 msgid "" "Return the length of a :class:`set` or :class:`frozenset` object. Equivalent " "to ``len(anyset)``. Raises a :exc:`SystemError` if *anyset* is not a :class:" "`set`, :class:`frozenset`, or an instance of a subtype." msgstr "" -#: ../../c-api/set.rst:119 +#: ../../c-api/set.rst:129 msgid "Macro form of :c:func:`PySet_Size` without error checking." msgstr "" -#: ../../c-api/set.rst:124 +#: ../../c-api/set.rst:134 msgid "" "Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is " "encountered. Unlike the Python :meth:`~object.__contains__` method, this " @@ -153,7 +163,14 @@ msgid "" "instance of a subtype." msgstr "" -#: ../../c-api/set.rst:133 +#: ../../c-api/set.rst:142 ../../c-api/set.rst:157 ../../c-api/set.rst:177 +msgid "" +"The operation is atomic on :term:`free threading ` when " +"*key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:" +"`bytes`." +msgstr "" + +#: ../../c-api/set.rst:147 msgid "" "Add *key* to a :class:`set` instance. Also works with :class:`frozenset` " "instances (like :c:func:`PyTuple_SetItem` it can be used to fill in the " @@ -164,13 +181,13 @@ msgid "" "`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:142 +#: ../../c-api/set.rst:162 msgid "" "The following functions are available for instances of :class:`set` or its " "subtypes but not for instances of :class:`frozenset` or its subtypes." msgstr "" -#: ../../c-api/set.rst:148 +#: ../../c-api/set.rst:168 msgid "" "Return ``1`` if found and removed, ``0`` if not found (no action taken), and " "``-1`` if an error is encountered. Does not raise :exc:`KeyError` for " @@ -180,7 +197,7 @@ msgid "" "if *set* is not an instance of :class:`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:158 +#: ../../c-api/set.rst:183 msgid "" "Return a new reference to an arbitrary object in the *set*, and removes the " "object from the *set*. Return ``NULL`` on failure. Raise :exc:`KeyError` " @@ -188,37 +205,44 @@ msgid "" "of :class:`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:166 +#: ../../c-api/set.rst:191 msgid "" "Empty an existing set of all elements. Return ``0`` on success. Return " "``-1`` and raise :exc:`SystemError` if *set* is not an instance of :class:" "`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:172 +#: ../../c-api/set.rst:197 +msgid "" +"In the :term:`free-threaded build`, the set is emptied before its entries " +"are cleared, so other threads will observe an empty set rather than " +"intermediate states." +msgstr "" + +#: ../../c-api/set.rst:203 msgid "Deprecated API" msgstr "已棄用的 API" -#: ../../c-api/set.rst:176 +#: ../../c-api/set.rst:207 msgid "" "A :term:`soft deprecated` constant representing the size of an internal " "preallocated table inside :c:type:`PySetObject` instances." msgstr "" -"一個被\\ :term:`軟性棄用 `\\ 的常數,代表 :c:type:`PySetObject` " -"實例內部預分配表格的大小。" +"一個被\\ :term:`軟性棄用 `\\ 的常數,代表 :c:type:" +"`PySetObject` 實例內部預分配表格的大小。" -#: ../../c-api/set.rst:179 +#: ../../c-api/set.rst:210 msgid "" "This is documented solely for completeness, as there are no guarantees that " "a given version of CPython uses preallocated tables with a fixed size. In " "code that does not deal with unstable set internals, :c:macro:`!" "PySet_MINSIZE` can be replaced with a small constant like ``8``." msgstr "" -"這僅為完整性而記錄於文件,且因為無法保證特定版本的 CPython 會使用具有固定大小的預分配表格。" -"在不處理不穩定集合內部結構的程式碼中,:c:macro:`!PySet_MINSIZE` 可以替換為像 ``8`` " -"這樣的小常數。" +"這僅為完整性而記錄於文件,且因為無法保證特定版本的 CPython 會使用具有固定大小" +"的預分配表格。在不處理不穩定集合內部結構的程式碼中,:c:macro:`!" +"PySet_MINSIZE` 可以替換為像 ``8`` 這樣的小常數。" -#: ../../c-api/set.rst:185 +#: ../../c-api/set.rst:216 msgid "If looking for the size of a set, use :c:func:`PySet_Size` instead." msgstr "如果要查詢集合的大小,請使用 :c:func:`PySet_Size`。" @@ -234,10 +258,10 @@ msgstr "set(集合)" msgid "frozenset" msgstr "frozenset(凍結集合)" -#: ../../c-api/set.rst:110 +#: ../../c-api/set.rst:120 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/set.rst:110 +#: ../../c-api/set.rst:120 msgid "len" msgstr "len" diff --git a/library/importlib.resources.po b/library/importlib.resources.po index 40d502c68fc..eadd35afcf2 100644 --- a/library/importlib.resources.po +++ b/library/importlib.resources.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-08 00:15+0000\n" +"POT-Creation-Date: 2026-04-12 00:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -60,6 +60,13 @@ msgstr "" #: ../../library/importlib.resources.rst:36 msgid "" +":mod:`importlib.resources` follows the same security model as the built-in :" +"func:`open` function. Passing untrusted inputs to the functions in this " +"module is unsafe." +msgstr "" + +#: ../../library/importlib.resources.rst:42 +msgid "" "This module provides functionality similar to `pkg_resources `_ `Basic Resource " "Access `_." msgstr "" -#: ../../library/importlib.resources.rst:50 +#: ../../library/importlib.resources.rst:56 msgid "" ":class:`Loaders ` that wish to support resource " "reading should implement a ``get_resource_reader(fullname)`` method as " "specified by :class:`importlib.resources.abc.ResourceReader`." msgstr "" -#: ../../library/importlib.resources.rst:56 +#: ../../library/importlib.resources.rst:62 msgid "" "Represents an anchor for resources, either a :class:`module object ` or a module name as a string. Defined as ``Union[str, " "ModuleType]``." msgstr "" -#: ../../library/importlib.resources.rst:62 +#: ../../library/importlib.resources.rst:68 msgid "" "Returns a :class:`~importlib.resources.abc.Traversable` object representing " "the resource container (think directory) and its resources (think files). A " "Traversable may contain other containers (think subdirectories)." msgstr "" -#: ../../library/importlib.resources.rst:67 +#: ../../library/importlib.resources.rst:73 msgid "" "*anchor* is an optional :class:`Anchor`. If the anchor is a package, " "resources are resolved from that package. If a module, resources are " @@ -105,7 +112,7 @@ msgid "" "If the anchor is omitted, the caller's module is used." msgstr "" -#: ../../library/importlib.resources.rst:75 +#: ../../library/importlib.resources.rst:81 msgid "" "*package* parameter was renamed to *anchor*. *anchor* can now be a non-" "package module and if omitted will default to the caller's module. *package* " @@ -114,7 +121,7 @@ msgid "" "``importlib_resources >= 5.10`` for a compatible interface on older Pythons." msgstr "" -#: ../../library/importlib.resources.rst:85 +#: ../../library/importlib.resources.rst:91 msgid "" "Given a :class:`~importlib.resources.abc.Traversable` object representing a " "file or directory, typically from :func:`importlib.resources.files`, return " @@ -122,60 +129,60 @@ msgid "" "manager provides a :class:`pathlib.Path` object." msgstr "" -#: ../../library/importlib.resources.rst:90 +#: ../../library/importlib.resources.rst:96 msgid "" "Exiting the context manager cleans up any temporary file or directory " "created when the resource was extracted from e.g. a zip file." msgstr "" -#: ../../library/importlib.resources.rst:93 +#: ../../library/importlib.resources.rst:99 msgid "" "Use ``as_file`` when the Traversable methods (``read_text``, etc) are " "insufficient and an actual file or directory on the file system is required." msgstr "" -#: ../../library/importlib.resources.rst:99 +#: ../../library/importlib.resources.rst:105 msgid "Added support for *traversable* representing a directory." msgstr "" -#: ../../library/importlib.resources.rst:106 +#: ../../library/importlib.resources.rst:112 msgid "Functional API" msgstr "" -#: ../../library/importlib.resources.rst:108 +#: ../../library/importlib.resources.rst:114 msgid "" "A set of simplified, backwards-compatible helpers is available. These allow " "common operations in a single function call." msgstr "" -#: ../../library/importlib.resources.rst:111 +#: ../../library/importlib.resources.rst:117 msgid "For all the following functions:" msgstr "" -#: ../../library/importlib.resources.rst:113 +#: ../../library/importlib.resources.rst:119 msgid "" "*anchor* is an :class:`~importlib.resources.Anchor`, as in :func:`~importlib." "resources.files`. Unlike in ``files``, it may not be omitted." msgstr "" -#: ../../library/importlib.resources.rst:117 +#: ../../library/importlib.resources.rst:123 msgid "" "*path_names* are components of a resource's path name, relative to the " "anchor. For example, to get the text of resource named ``info.txt``, use::" msgstr "" -#: ../../library/importlib.resources.rst:121 +#: ../../library/importlib.resources.rst:127 msgid "importlib.resources.read_text(my_module, \"info.txt\")" msgstr "importlib.resources.read_text(my_module, \"info.txt\")" -#: ../../library/importlib.resources.rst:123 +#: ../../library/importlib.resources.rst:129 msgid "" "Like :meth:`Traversable.joinpath `, The " "individual components should use forward slashes (``/``) as path separators. " "For example, the following are equivalent::" msgstr "" -#: ../../library/importlib.resources.rst:128 +#: ../../library/importlib.resources.rst:134 msgid "" "importlib.resources.read_binary(my_module, \"pics/painting.png\")\n" "importlib.resources.read_binary(my_module, \"pics\", \"painting.png\")" @@ -183,14 +190,14 @@ msgstr "" "importlib.resources.read_binary(my_module, \"pics/painting.png\")\n" "importlib.resources.read_binary(my_module, \"pics\", \"painting.png\")" -#: ../../library/importlib.resources.rst:131 +#: ../../library/importlib.resources.rst:137 msgid "" "For backward compatibility reasons, functions that read text require an " "explicit *encoding* argument if multiple *path_names* are given. For " "example, to get the text of ``info/chapter1.txt``, use::" msgstr "" -#: ../../library/importlib.resources.rst:135 +#: ../../library/importlib.resources.rst:141 msgid "" "importlib.resources.read_text(my_module, \"info\", \"chapter1.txt\",\n" " encoding='utf-8')" @@ -198,124 +205,124 @@ msgstr "" "importlib.resources.read_text(my_module, \"info\", \"chapter1.txt\",\n" " encoding='utf-8')" -#: ../../library/importlib.resources.rst:140 +#: ../../library/importlib.resources.rst:146 msgid "Open the named resource for binary reading." msgstr "" -#: ../../library/importlib.resources.rst:142 -#: ../../library/importlib.resources.rst:185 -#: ../../library/importlib.resources.rst:233 -#: ../../library/importlib.resources.rst:250 -#: ../../library/importlib.resources.rst:268 +#: ../../library/importlib.resources.rst:148 +#: ../../library/importlib.resources.rst:191 +#: ../../library/importlib.resources.rst:239 +#: ../../library/importlib.resources.rst:256 +#: ../../library/importlib.resources.rst:274 msgid "" "See :ref:`the introduction ` for details on " "*anchor* and *path_names*." msgstr "" -#: ../../library/importlib.resources.rst:145 +#: ../../library/importlib.resources.rst:151 msgid "" "This function returns a :class:`~typing.BinaryIO` object, that is, a binary " "stream open for reading." msgstr "" -#: ../../library/importlib.resources.rst:148 -#: ../../library/importlib.resources.rst:172 -#: ../../library/importlib.resources.rst:188 -#: ../../library/importlib.resources.rst:209 -#: ../../library/importlib.resources.rst:236 -#: ../../library/importlib.resources.rst:253 -#: ../../library/importlib.resources.rst:271 +#: ../../library/importlib.resources.rst:154 +#: ../../library/importlib.resources.rst:178 +#: ../../library/importlib.resources.rst:194 +#: ../../library/importlib.resources.rst:215 +#: ../../library/importlib.resources.rst:242 +#: ../../library/importlib.resources.rst:259 +#: ../../library/importlib.resources.rst:277 msgid "This function is roughly equivalent to::" msgstr "這個函式大致等同於: ::" -#: ../../library/importlib.resources.rst:150 +#: ../../library/importlib.resources.rst:156 msgid "files(anchor).joinpath(*path_names).open('rb')" msgstr "files(anchor).joinpath(*path_names).open('rb')" -#: ../../library/importlib.resources.rst:152 -#: ../../library/importlib.resources.rst:192 -#: ../../library/importlib.resources.rst:257 +#: ../../library/importlib.resources.rst:158 +#: ../../library/importlib.resources.rst:198 +#: ../../library/importlib.resources.rst:263 msgid "Multiple *path_names* are accepted." msgstr "多個 *path_names* 是被接受的。" -#: ../../library/importlib.resources.rst:158 +#: ../../library/importlib.resources.rst:164 msgid "" "Open the named resource for text reading. By default, the contents are read " "as strict UTF-8." msgstr "" -#: ../../library/importlib.resources.rst:161 -#: ../../library/importlib.resources.rst:201 +#: ../../library/importlib.resources.rst:167 +#: ../../library/importlib.resources.rst:207 msgid "" "See :ref:`the introduction ` for details on " "*anchor* and *path_names*. *encoding* and *errors* have the same meaning as " "in built-in :func:`open`." msgstr "" -#: ../../library/importlib.resources.rst:165 -#: ../../library/importlib.resources.rst:205 +#: ../../library/importlib.resources.rst:171 +#: ../../library/importlib.resources.rst:211 msgid "" "For backward compatibility reasons, the *encoding* argument must be given " "explicitly if there are multiple *path_names*. This limitation is scheduled " "to be removed in Python 3.15." msgstr "" -#: ../../library/importlib.resources.rst:169 +#: ../../library/importlib.resources.rst:175 msgid "" "This function returns a :class:`~typing.TextIO` object, that is, a text " "stream open for reading." msgstr "" -#: ../../library/importlib.resources.rst:174 +#: ../../library/importlib.resources.rst:180 msgid "files(anchor).joinpath(*path_names).open('r', encoding=encoding)" msgstr "files(anchor).joinpath(*path_names).open('r', encoding=encoding)" -#: ../../library/importlib.resources.rst:176 -#: ../../library/importlib.resources.rst:213 -#: ../../library/importlib.resources.rst:240 +#: ../../library/importlib.resources.rst:182 +#: ../../library/importlib.resources.rst:219 +#: ../../library/importlib.resources.rst:246 msgid "" "Multiple *path_names* are accepted. *encoding* and *errors* must be given as " "keyword arguments." msgstr "" -#: ../../library/importlib.resources.rst:183 +#: ../../library/importlib.resources.rst:189 msgid "Read and return the contents of the named resource as :class:`bytes`." msgstr "以 :class:`bytes` 形式讀取並回傳指定資源的內容。" -#: ../../library/importlib.resources.rst:190 +#: ../../library/importlib.resources.rst:196 msgid "files(anchor).joinpath(*path_names).read_bytes()" msgstr "files(anchor).joinpath(*path_names).read_bytes()" -#: ../../library/importlib.resources.rst:198 +#: ../../library/importlib.resources.rst:204 msgid "" "Read and return the contents of the named resource as :class:`str`. By " "default, the contents are read as strict UTF-8." msgstr "" -#: ../../library/importlib.resources.rst:211 +#: ../../library/importlib.resources.rst:217 msgid "files(anchor).joinpath(*path_names).read_text(encoding=encoding)" msgstr "files(anchor).joinpath(*path_names).read_text(encoding=encoding)" -#: ../../library/importlib.resources.rst:220 +#: ../../library/importlib.resources.rst:226 msgid "" "Provides the path to the *resource* as an actual file system path. This " "function returns a context manager for use in a :keyword:`with` statement. " "The context manager provides a :class:`pathlib.Path` object." msgstr "" -#: ../../library/importlib.resources.rst:224 +#: ../../library/importlib.resources.rst:230 msgid "" "Exiting the context manager cleans up any temporary files created, e.g. when " "the resource needs to be extracted from a zip file." msgstr "" -#: ../../library/importlib.resources.rst:227 +#: ../../library/importlib.resources.rst:233 msgid "" "For example, the :meth:`~pathlib.Path.stat` method requires an actual file " "system path; it can be used like this::" msgstr "" -#: ../../library/importlib.resources.rst:230 +#: ../../library/importlib.resources.rst:236 msgid "" "with importlib.resources.path(anchor, \"resource.txt\") as fspath:\n" " result = fspath.stat()" @@ -323,21 +330,21 @@ msgstr "" "with importlib.resources.path(anchor, \"resource.txt\") as fspath:\n" " result = fspath.stat()" -#: ../../library/importlib.resources.rst:238 +#: ../../library/importlib.resources.rst:244 msgid "as_file(files(anchor).joinpath(*path_names))" msgstr "as_file(files(anchor).joinpath(*path_names))" -#: ../../library/importlib.resources.rst:247 +#: ../../library/importlib.resources.rst:253 msgid "" "Return ``True`` if the named resource exists, otherwise ``False``. This " "function does not consider directories to be resources." msgstr "" -#: ../../library/importlib.resources.rst:255 +#: ../../library/importlib.resources.rst:261 msgid "files(anchor).joinpath(*path_names).is_file()" msgstr "files(anchor).joinpath(*path_names).is_file()" -#: ../../library/importlib.resources.rst:263 +#: ../../library/importlib.resources.rst:269 msgid "" "Return an iterable over the named items within the package or path. The " "iterable returns names of resources (e.g. files) and non-resources (e.g. " @@ -345,7 +352,7 @@ msgid "" "subdirectories." msgstr "" -#: ../../library/importlib.resources.rst:273 +#: ../../library/importlib.resources.rst:279 msgid "" "for resource in files(anchor).joinpath(*path_names).iterdir():\n" " yield resource.name" @@ -353,7 +360,7 @@ msgstr "" "for resource in files(anchor).joinpath(*path_names).iterdir():\n" " yield resource.name" -#: ../../library/importlib.resources.rst:276 +#: ../../library/importlib.resources.rst:282 msgid "" "Prefer ``iterdir()`` as above, which offers more control over the results " "and richer functionality." From 668236615ff932cd9dcb818dfd5905eb6c56c3c7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 13 Apr 2026 00:27:42 +0000 Subject: [PATCH 3/3] sync with cpython 942d3024 --- library/multiprocessing.po | 957 +++++++++++++++++++------------------ 1 file changed, 479 insertions(+), 478 deletions(-) diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 84d4985ea39..e3093d27ac2 100644 --- a/library/multiprocessing.po +++ b/library/multiprocessing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 00:20+0000\n" +"POT-Creation-Date: 2026-04-13 00:26+0000\n" "PO-Revision-Date: 2018-05-23 16:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1482,15 +1482,15 @@ msgid "" "is started which transfers objects from a buffer into the pipe." msgstr "" -#: ../../library/multiprocessing.rst:928 ../../library/multiprocessing.rst:1046 -#: ../../library/multiprocessing.rst:1079 -#: ../../library/multiprocessing.rst:1435 -#: ../../library/multiprocessing.rst:1445 -#: ../../library/multiprocessing.rst:1468 -#: ../../library/multiprocessing.rst:1478 -#: ../../library/multiprocessing.rst:1495 -#: ../../library/multiprocessing.rst:1555 -#: ../../library/multiprocessing.rst:1617 +#: ../../library/multiprocessing.rst:928 ../../library/multiprocessing.rst:1047 +#: ../../library/multiprocessing.rst:1080 +#: ../../library/multiprocessing.rst:1436 +#: ../../library/multiprocessing.rst:1446 +#: ../../library/multiprocessing.rst:1469 +#: ../../library/multiprocessing.rst:1479 +#: ../../library/multiprocessing.rst:1496 +#: ../../library/multiprocessing.rst:1556 +#: ../../library/multiprocessing.rst:1618 msgid "" "Instantiating this class may set the global start method. See :ref:`global-" "start-method` for more details." @@ -1505,38 +1505,39 @@ msgstr "" #: ../../library/multiprocessing.rst:934 msgid "" ":class:`Queue` implements all the methods of :class:`queue.Queue` except " -"for :meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join`." +"for :meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`, and :meth:" +"`~queue.Queue.shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:939 +#: ../../library/multiprocessing.rst:940 msgid "" "Return the approximate size of the queue. Because of multithreading/" "multiprocessing semantics, this number is not reliable." msgstr "" -#: ../../library/multiprocessing.rst:942 ../../library/multiprocessing.rst:1628 +#: ../../library/multiprocessing.rst:943 ../../library/multiprocessing.rst:1629 msgid "" "Note that this may raise :exc:`NotImplementedError` on platforms like macOS " "where ``sem_getvalue()`` is not implemented." msgstr "" -#: ../../library/multiprocessing.rst:947 +#: ../../library/multiprocessing.rst:948 msgid "" "Return ``True`` if the queue is empty, ``False`` otherwise. Because of " "multithreading/multiprocessing semantics, this is not reliable." msgstr "" -#: ../../library/multiprocessing.rst:950 +#: ../../library/multiprocessing.rst:951 msgid "May raise an :exc:`OSError` on closed queues. (not guaranteed)" msgstr "" -#: ../../library/multiprocessing.rst:954 +#: ../../library/multiprocessing.rst:955 msgid "" "Return ``True`` if the queue is full, ``False`` otherwise. Because of " "multithreading/multiprocessing semantics, this is not reliable." msgstr "" -#: ../../library/multiprocessing.rst:959 +#: ../../library/multiprocessing.rst:960 msgid "" "Put obj into the queue. If the optional argument *block* is ``True`` (the " "default) and *timeout* is ``None`` (the default), block if necessary until a " @@ -1547,17 +1548,17 @@ msgid "" "the :exc:`queue.Full` exception (*timeout* is ignored in that case)." msgstr "" -#: ../../library/multiprocessing.rst:968 +#: ../../library/multiprocessing.rst:969 msgid "" "If the queue is closed, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:974 +#: ../../library/multiprocessing.rst:975 msgid "Equivalent to ``put(obj, False)``." msgstr "相當於 ``put(obj, False)``。" -#: ../../library/multiprocessing.rst:978 +#: ../../library/multiprocessing.rst:979 msgid "" "Remove and return an item from the queue. If optional args *block* is " "``True`` (the default) and *timeout* is ``None`` (the default), block if " @@ -1568,62 +1569,62 @@ msgid "" "Empty` exception (*timeout* is ignored in that case)." msgstr "" -#: ../../library/multiprocessing.rst:986 +#: ../../library/multiprocessing.rst:987 msgid "" "If the queue is closed, :exc:`ValueError` is raised instead of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:992 +#: ../../library/multiprocessing.rst:993 msgid "Equivalent to ``get(False)``." msgstr "相當於 ``get(False)``。" -#: ../../library/multiprocessing.rst:994 +#: ../../library/multiprocessing.rst:995 msgid "" ":class:`multiprocessing.Queue` has a few additional methods not found in :" "class:`queue.Queue`. These methods are usually unnecessary for most code:" msgstr "" -#: ../../library/multiprocessing.rst:1000 -#: ../../library/multiprocessing.rst:1051 +#: ../../library/multiprocessing.rst:1001 +#: ../../library/multiprocessing.rst:1052 msgid "Close the queue: release internal resources." msgstr "" -#: ../../library/multiprocessing.rst:1002 +#: ../../library/multiprocessing.rst:1003 msgid "" "A queue must not be used anymore after it is closed. For example, :meth:" "`~Queue.get`, :meth:`~Queue.put` and :meth:`~Queue.empty` methods must no " "longer be called." msgstr "" -#: ../../library/multiprocessing.rst:1006 +#: ../../library/multiprocessing.rst:1007 msgid "" "The background thread will quit once it has flushed all buffered data to the " "pipe. This is called automatically when the queue is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1012 +#: ../../library/multiprocessing.rst:1013 msgid "" "Join the background thread. This can only be used after :meth:`close` has " "been called. It blocks until the background thread exits, ensuring that all " "data in the buffer has been flushed to the pipe." msgstr "" -#: ../../library/multiprocessing.rst:1016 +#: ../../library/multiprocessing.rst:1017 msgid "" "By default if a process is not the creator of the queue then on exit it will " "attempt to join the queue's background thread. The process can call :meth:" "`cancel_join_thread` to make :meth:`join_thread` do nothing." msgstr "" -#: ../../library/multiprocessing.rst:1022 +#: ../../library/multiprocessing.rst:1023 msgid "" "Prevent :meth:`join_thread` from blocking. In particular, this prevents the " "background thread from being joined automatically when the process exits -- " "see :meth:`join_thread`." msgstr "" -#: ../../library/multiprocessing.rst:1026 +#: ../../library/multiprocessing.rst:1027 msgid "" "A better name for this method might be ``allow_exit_without_flush()``. It " "is likely to cause enqueued data to be lost, and you almost certainly will " @@ -1632,7 +1633,7 @@ msgid "" "pipe, and you don't care about lost data." msgstr "" -#: ../../library/multiprocessing.rst:1035 +#: ../../library/multiprocessing.rst:1036 msgid "" "This class's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the functionality " @@ -1642,40 +1643,40 @@ msgid "" "listed below." msgstr "" -#: ../../library/multiprocessing.rst:1044 +#: ../../library/multiprocessing.rst:1045 msgid "" "It is a simplified :class:`Queue` type, very close to a locked :class:`Pipe`." msgstr "" -#: ../../library/multiprocessing.rst:1053 +#: ../../library/multiprocessing.rst:1054 msgid "" "A queue must not be used anymore after it is closed. For example, :meth:" "`get`, :meth:`put` and :meth:`empty` methods must no longer be called." msgstr "" -#: ../../library/multiprocessing.rst:1061 +#: ../../library/multiprocessing.rst:1062 msgid "Return ``True`` if the queue is empty, ``False`` otherwise." msgstr "" -#: ../../library/multiprocessing.rst:1063 +#: ../../library/multiprocessing.rst:1064 msgid "Always raises an :exc:`OSError` if the SimpleQueue is closed." msgstr "" -#: ../../library/multiprocessing.rst:1067 +#: ../../library/multiprocessing.rst:1068 msgid "Remove and return an item from the queue." msgstr "" -#: ../../library/multiprocessing.rst:1071 +#: ../../library/multiprocessing.rst:1072 msgid "Put *item* into the queue." msgstr "" -#: ../../library/multiprocessing.rst:1076 +#: ../../library/multiprocessing.rst:1077 msgid "" ":class:`JoinableQueue`, a :class:`Queue` subclass, is a queue which " "additionally has :meth:`task_done` and :meth:`join` methods." msgstr "" -#: ../../library/multiprocessing.rst:1084 +#: ../../library/multiprocessing.rst:1085 msgid "" "Indicate that a formerly enqueued task is complete. Used by queue " "consumers. For each :meth:`~Queue.get` used to fetch a task, a subsequent " @@ -1683,24 +1684,24 @@ msgid "" "complete." msgstr "" -#: ../../library/multiprocessing.rst:1089 +#: ../../library/multiprocessing.rst:1090 msgid "" "If a :meth:`~queue.Queue.join` is currently blocking, it will resume when " "all items have been processed (meaning that a :meth:`task_done` call was " "received for every item that had been :meth:`~Queue.put` into the queue)." msgstr "" -#: ../../library/multiprocessing.rst:1093 +#: ../../library/multiprocessing.rst:1094 msgid "" "Raises a :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "" -#: ../../library/multiprocessing.rst:1099 +#: ../../library/multiprocessing.rst:1100 msgid "Block until all items in the queue have been gotten and processed." msgstr "" -#: ../../library/multiprocessing.rst:1101 +#: ../../library/multiprocessing.rst:1102 msgid "" "The count of unfinished tasks goes up whenever an item is added to the " "queue. The count goes down whenever a consumer calls :meth:`task_done` to " @@ -1709,78 +1710,78 @@ msgid "" "unblocks." msgstr "" -#: ../../library/multiprocessing.rst:1109 +#: ../../library/multiprocessing.rst:1110 msgid "Miscellaneous" msgstr "" -#: ../../library/multiprocessing.rst:1113 +#: ../../library/multiprocessing.rst:1114 msgid "Return list of all live children of the current process." msgstr "" -#: ../../library/multiprocessing.rst:1115 +#: ../../library/multiprocessing.rst:1116 msgid "" "Calling this has the side effect of \"joining\" any processes which have " "already finished." msgstr "" -#: ../../library/multiprocessing.rst:1120 +#: ../../library/multiprocessing.rst:1121 msgid "Return the number of CPUs in the system." msgstr "" -#: ../../library/multiprocessing.rst:1122 +#: ../../library/multiprocessing.rst:1123 msgid "" "This number is not equivalent to the number of CPUs the current process can " "use. The number of usable CPUs can be obtained with :func:`os." "process_cpu_count` (or ``len(os.sched_getaffinity(0))``)." msgstr "" -#: ../../library/multiprocessing.rst:1126 +#: ../../library/multiprocessing.rst:1127 msgid "" "When the number of CPUs cannot be determined a :exc:`NotImplementedError` is " "raised." msgstr "" -#: ../../library/multiprocessing.rst:1130 +#: ../../library/multiprocessing.rst:1131 msgid ":func:`os.cpu_count` :func:`os.process_cpu_count`" msgstr ":func:`os.cpu_count` :func:`os.process_cpu_count`" -#: ../../library/multiprocessing.rst:1135 +#: ../../library/multiprocessing.rst:1136 msgid "" "The return value can also be overridden using the :option:`-X cpu_count <-" "X>` flag or :envvar:`PYTHON_CPU_COUNT` as this is merely a wrapper around " "the :mod:`os` cpu count APIs." msgstr "" -#: ../../library/multiprocessing.rst:1141 +#: ../../library/multiprocessing.rst:1142 msgid "" "Return the :class:`Process` object corresponding to the current process." msgstr "" -#: ../../library/multiprocessing.rst:1143 +#: ../../library/multiprocessing.rst:1144 msgid "An analogue of :func:`threading.current_thread`." msgstr "" -#: ../../library/multiprocessing.rst:1147 +#: ../../library/multiprocessing.rst:1148 msgid "" "Return the :class:`Process` object corresponding to the parent process of " "the :func:`current_process`. For the main process, ``parent_process`` will " "be ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1155 +#: ../../library/multiprocessing.rst:1156 msgid "" "Add support for when a program which uses :mod:`!multiprocessing` has been " "frozen to produce an executable. (Has been tested with **py2exe**, " "**PyInstaller** and **cx_Freeze**.)" msgstr "" -#: ../../library/multiprocessing.rst:1159 +#: ../../library/multiprocessing.rst:1160 msgid "" "One needs to call this function straight after the ``if __name__ == " "'__main__'`` line of the main module. For example::" msgstr "" -#: ../../library/multiprocessing.rst:1162 +#: ../../library/multiprocessing.rst:1163 msgid "" "from multiprocessing import Process, freeze_support\n" "\n" @@ -1800,13 +1801,13 @@ msgstr "" " freeze_support()\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:1171 +#: ../../library/multiprocessing.rst:1172 msgid "" "If the ``freeze_support()`` line is omitted then trying to run the frozen " "executable will raise :exc:`RuntimeError`." msgstr "" -#: ../../library/multiprocessing.rst:1174 +#: ../../library/multiprocessing.rst:1175 msgid "" "Calling ``freeze_support()`` has no effect when the start method is not " "*spawn*. In addition, if the module is being run normally by the Python " @@ -1814,7 +1815,7 @@ msgid "" "no effect." msgstr "" -#: ../../library/multiprocessing.rst:1181 +#: ../../library/multiprocessing.rst:1182 msgid "" "Returns a list of the supported start methods, the first of which is the " "default. The possible start methods are ``'fork'``, ``'spawn'`` and " @@ -1822,13 +1823,13 @@ msgid "" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1190 +#: ../../library/multiprocessing.rst:1191 msgid "" "Return a context object which has the same attributes as the :mod:`!" "multiprocessing` module." msgstr "" -#: ../../library/multiprocessing.rst:1193 +#: ../../library/multiprocessing.rst:1194 msgid "" "If *method* is ``None`` then the default context is returned. Note that if " "the global start method has not been set, this will set it to the system " @@ -1838,54 +1839,54 @@ msgid "" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1204 +#: ../../library/multiprocessing.rst:1205 msgid "Return the name of start method used for starting processes." msgstr "" -#: ../../library/multiprocessing.rst:1206 +#: ../../library/multiprocessing.rst:1207 msgid "" "If the global start method is not set and *allow_none* is ``False``, the " "global start method is set to the default, and its name is returned. See :" "ref:`global-start-method` for more details." msgstr "" -#: ../../library/multiprocessing.rst:1210 +#: ../../library/multiprocessing.rst:1211 msgid "" "The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` or " "``None``. See :ref:`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1217 +#: ../../library/multiprocessing.rst:1218 msgid "" "On macOS, the *spawn* start method is now the default. The *fork* start " "method should be considered unsafe as it can lead to crashes of the " "subprocess. See :issue:`33725`." msgstr "" -#: ../../library/multiprocessing.rst:1223 +#: ../../library/multiprocessing.rst:1224 msgid "" "Set the path of the Python interpreter to use when starting a child process. " "(By default :data:`sys.executable` is used). Embedders will probably need " "to do something like ::" msgstr "" -#: ../../library/multiprocessing.rst:1227 +#: ../../library/multiprocessing.rst:1228 msgid "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" msgstr "set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))" -#: ../../library/multiprocessing.rst:1229 +#: ../../library/multiprocessing.rst:1230 msgid "before they can create child processes." msgstr "" -#: ../../library/multiprocessing.rst:1231 +#: ../../library/multiprocessing.rst:1232 msgid "Now supported on POSIX when the ``'spawn'`` start method is used." msgstr "" -#: ../../library/multiprocessing.rst:1234 +#: ../../library/multiprocessing.rst:1235 msgid "Accepts a :term:`path-like object`." msgstr "接受一個\\ :term:`類路徑物件 `。" -#: ../../library/multiprocessing.rst:1239 +#: ../../library/multiprocessing.rst:1240 msgid "" "Set a list of module names for the forkserver main process to attempt to " "import so that their already imported state is inherited by forked " @@ -1894,19 +1895,19 @@ msgid "" "process." msgstr "" -#: ../../library/multiprocessing.rst:1245 +#: ../../library/multiprocessing.rst:1246 msgid "" "For this to work, it must be called before the forkserver process has been " "launched (before creating a :class:`Pool` or starting a :class:`Process`)." msgstr "" -#: ../../library/multiprocessing.rst:1248 +#: ../../library/multiprocessing.rst:1249 msgid "" "Only meaningful when using the ``'forkserver'`` start method. See :ref:" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1255 +#: ../../library/multiprocessing.rst:1256 msgid "" "Set the method which should be used to start child processes. The *method* " "argument can be ``'fork'``, ``'spawn'`` or ``'forkserver'``. Raises :exc:" @@ -1916,17 +1917,17 @@ msgid "" "then the context is set to the default context." msgstr "" -#: ../../library/multiprocessing.rst:1262 +#: ../../library/multiprocessing.rst:1263 msgid "" "Note that this should be called at most once, and it should be protected " "inside the ``if __name__ == '__main__'`` clause of the main module." msgstr "" -#: ../../library/multiprocessing.rst:1266 +#: ../../library/multiprocessing.rst:1267 msgid "See :ref:`multiprocessing-start-methods`." msgstr "參閱 :ref:`multiprocessing-start-methods`。" -#: ../../library/multiprocessing.rst:1272 +#: ../../library/multiprocessing.rst:1273 msgid "" ":mod:`!multiprocessing` contains no analogues of :func:`threading." "active_count`, :func:`threading.enumerate`, :func:`threading.settrace`, :" @@ -1934,75 +1935,75 @@ msgid "" "local`." msgstr "" -#: ../../library/multiprocessing.rst:1279 +#: ../../library/multiprocessing.rst:1280 msgid "Connection Objects" msgstr "" -#: ../../library/multiprocessing.rst:1283 +#: ../../library/multiprocessing.rst:1284 msgid "" "Connection objects allow the sending and receiving of picklable objects or " "strings. They can be thought of as message oriented connected sockets." msgstr "" -#: ../../library/multiprocessing.rst:1286 +#: ../../library/multiprocessing.rst:1287 msgid "" "Connection objects are usually created using :func:`Pipe ` -- see also :ref:`multiprocessing-listeners-clients`." msgstr "" -#: ../../library/multiprocessing.rst:1294 +#: ../../library/multiprocessing.rst:1295 msgid "" "Send an object to the other end of the connection which should be read " "using :meth:`recv`." msgstr "" -#: ../../library/multiprocessing.rst:1297 +#: ../../library/multiprocessing.rst:1298 msgid "" "The object must be picklable. Very large pickles (approximately 32 MiB+, " "though it depends on the OS) may raise a :exc:`ValueError` exception." msgstr "" -#: ../../library/multiprocessing.rst:1302 +#: ../../library/multiprocessing.rst:1303 msgid "" "Return an object sent from the other end of the connection using :meth:" "`send`. Blocks until there is something to receive. Raises :exc:`EOFError` " "if there is nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1309 +#: ../../library/multiprocessing.rst:1310 msgid "Return the file descriptor or handle used by the connection." msgstr "" -#: ../../library/multiprocessing.rst:1313 +#: ../../library/multiprocessing.rst:1314 msgid "Close the connection." msgstr "" -#: ../../library/multiprocessing.rst:1315 +#: ../../library/multiprocessing.rst:1316 msgid "This is called automatically when the connection is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1319 +#: ../../library/multiprocessing.rst:1320 msgid "Return whether there is any data available to be read." msgstr "" -#: ../../library/multiprocessing.rst:1321 +#: ../../library/multiprocessing.rst:1322 msgid "" "If *timeout* is not specified then it will return immediately. If *timeout* " "is a number then this specifies the maximum time in seconds to block. If " "*timeout* is ``None`` then an infinite timeout is used." msgstr "" -#: ../../library/multiprocessing.rst:1325 +#: ../../library/multiprocessing.rst:1326 msgid "" "Note that multiple connection objects may be polled at once by using :func:" "`multiprocessing.connection.wait`." msgstr "" -#: ../../library/multiprocessing.rst:1330 +#: ../../library/multiprocessing.rst:1331 msgid "Send byte data from a :term:`bytes-like object` as a complete message." msgstr "" -#: ../../library/multiprocessing.rst:1332 +#: ../../library/multiprocessing.rst:1333 msgid "" "If *offset* is given then data is read from that position in *buffer*. If " "*size* is given then that many bytes will be read from buffer. Very large " @@ -2010,7 +2011,7 @@ msgid "" "exc:`ValueError` exception" msgstr "" -#: ../../library/multiprocessing.rst:1339 +#: ../../library/multiprocessing.rst:1340 msgid "" "Return a complete message of byte data sent from the other end of the " "connection as a string. Blocks until there is something to receive. Raises :" @@ -2018,19 +2019,19 @@ msgid "" "closed." msgstr "" -#: ../../library/multiprocessing.rst:1344 +#: ../../library/multiprocessing.rst:1345 msgid "" "If *maxlength* is specified and the message is longer than *maxlength* then :" "exc:`OSError` is raised and the connection will no longer be readable." msgstr "" -#: ../../library/multiprocessing.rst:1348 +#: ../../library/multiprocessing.rst:1349 msgid "" "This function used to raise :exc:`IOError`, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:1355 +#: ../../library/multiprocessing.rst:1356 msgid "" "Read into *buffer* a complete message of byte data sent from the other end " "of the connection and return the number of bytes in the message. Blocks " @@ -2038,38 +2039,38 @@ msgid "" "nothing left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1361 +#: ../../library/multiprocessing.rst:1362 msgid "" "*buffer* must be a writable :term:`bytes-like object`. If *offset* is given " "then the message will be written into the buffer from that position. Offset " "must be a non-negative integer less than the length of *buffer* (in bytes)." msgstr "" -#: ../../library/multiprocessing.rst:1366 +#: ../../library/multiprocessing.rst:1367 msgid "" "If the buffer is too short then a :exc:`BufferTooShort` exception is raised " "and the complete message is available as ``e.args[0]`` where ``e`` is the " "exception instance." msgstr "" -#: ../../library/multiprocessing.rst:1370 +#: ../../library/multiprocessing.rst:1371 msgid "" "Connection objects themselves can now be transferred between processes " "using :meth:`Connection.send` and :meth:`Connection.recv`." msgstr "" -#: ../../library/multiprocessing.rst:1374 +#: ../../library/multiprocessing.rst:1375 msgid "" "Connection objects also now support the context management protocol -- see :" "ref:`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "connection object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:1378 +#: ../../library/multiprocessing.rst:1379 msgid "For example:" msgstr "舉例來說:" -#: ../../library/multiprocessing.rst:1380 +#: ../../library/multiprocessing.rst:1381 msgid "" ">>> from multiprocessing import Pipe\n" ">>> a, b = Pipe()\n" @@ -2105,14 +2106,14 @@ msgstr "" ">>> arr2\n" "array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])" -#: ../../library/multiprocessing.rst:1403 +#: ../../library/multiprocessing.rst:1404 msgid "" "The :meth:`Connection.recv` method automatically unpickles the data it " "receives, which can be a security risk unless you can trust the process " "which sent the message." msgstr "" -#: ../../library/multiprocessing.rst:1407 +#: ../../library/multiprocessing.rst:1408 msgid "" "Therefore, unless the connection object was produced using :func:`Pipe` you " "should only use the :meth:`~Connection.recv` and :meth:`~Connection.send` " @@ -2120,80 +2121,80 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:1414 +#: ../../library/multiprocessing.rst:1415 msgid "" "If a process is killed while it is trying to read or write to a pipe then " "the data in the pipe is likely to become corrupted, because it may become " "impossible to be sure where the message boundaries lie." msgstr "" -#: ../../library/multiprocessing.rst:1420 +#: ../../library/multiprocessing.rst:1421 msgid "Synchronization primitives" msgstr "" -#: ../../library/multiprocessing.rst:1424 +#: ../../library/multiprocessing.rst:1425 msgid "" "Generally synchronization primitives are not as necessary in a multiprocess " "program as they are in a multithreaded program. See the documentation for :" "mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:1428 +#: ../../library/multiprocessing.rst:1429 msgid "" "Note that one can also create synchronization primitives by using a manager " "object -- see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:1433 +#: ../../library/multiprocessing.rst:1434 msgid "A barrier object: a clone of :class:`threading.Barrier`." msgstr "" -#: ../../library/multiprocessing.rst:1442 +#: ../../library/multiprocessing.rst:1443 msgid "" "A bounded semaphore object: a close analog of :class:`threading." "BoundedSemaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1448 -#: ../../library/multiprocessing.rst:1620 +#: ../../library/multiprocessing.rst:1449 +#: ../../library/multiprocessing.rst:1621 msgid "" "A solitary difference from its close analog exists: its ``acquire`` method's " "first argument is named *block*, as is consistent with :meth:`Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1453 -#: ../../library/multiprocessing.rst:1538 -#: ../../library/multiprocessing.rst:1608 -#: ../../library/multiprocessing.rst:1634 +#: ../../library/multiprocessing.rst:1454 +#: ../../library/multiprocessing.rst:1539 +#: ../../library/multiprocessing.rst:1609 +#: ../../library/multiprocessing.rst:1635 msgid "Return a boolean indicating whether this object is locked right now." msgstr "" -#: ../../library/multiprocessing.rst:1458 +#: ../../library/multiprocessing.rst:1459 msgid "" "On macOS, this is indistinguishable from :class:`Semaphore` because " "``sem_getvalue()`` is not implemented on that platform." msgstr "" -#: ../../library/multiprocessing.rst:1463 +#: ../../library/multiprocessing.rst:1464 msgid "A condition variable: an alias for :class:`threading.Condition`." msgstr "" -#: ../../library/multiprocessing.rst:1465 +#: ../../library/multiprocessing.rst:1466 msgid "" "If *lock* is specified then it should be a :class:`Lock` or :class:`RLock` " "object from :mod:`!multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:1471 -#: ../../library/multiprocessing.rst:2066 +#: ../../library/multiprocessing.rst:1472 +#: ../../library/multiprocessing.rst:2067 msgid "The :meth:`~threading.Condition.wait_for` method was added." msgstr "新增 :meth:`~threading.Condition.wait_for` 方法。" -#: ../../library/multiprocessing.rst:1476 +#: ../../library/multiprocessing.rst:1477 msgid "A clone of :class:`threading.Event`." msgstr "" -#: ../../library/multiprocessing.rst:1483 +#: ../../library/multiprocessing.rst:1484 msgid "" "A non-recursive lock object: a close analog of :class:`threading.Lock`. Once " "a process or thread has acquired a lock, subsequent attempts to acquire it " @@ -2204,25 +2205,25 @@ msgid "" "as noted." msgstr "" -#: ../../library/multiprocessing.rst:1491 +#: ../../library/multiprocessing.rst:1492 msgid "" "Note that :class:`Lock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.Lock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1498 +#: ../../library/multiprocessing.rst:1499 msgid "" ":class:`Lock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1503 -#: ../../library/multiprocessing.rst:1564 +#: ../../library/multiprocessing.rst:1504 +#: ../../library/multiprocessing.rst:1565 msgid "Acquire a lock, blocking or non-blocking." msgstr "" -#: ../../library/multiprocessing.rst:1505 +#: ../../library/multiprocessing.rst:1506 msgid "" "With the *block* argument set to ``True`` (the default), the method call " "will block until the lock is in an unlocked state, then set it to locked and " @@ -2230,14 +2231,14 @@ msgid "" "that in :meth:`threading.Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1510 +#: ../../library/multiprocessing.rst:1511 msgid "" "With the *block* argument set to ``False``, the method call does not block. " "If the lock is currently in a locked state, return ``False``; otherwise set " "the lock to a locked state and return ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1514 +#: ../../library/multiprocessing.rst:1515 msgid "" "When invoked with a positive, floating-point value for *timeout*, block for " "at most the number of seconds specified by *timeout* as long as the lock can " @@ -2251,19 +2252,19 @@ msgid "" "acquired or ``False`` if the timeout period has elapsed." msgstr "" -#: ../../library/multiprocessing.rst:1529 +#: ../../library/multiprocessing.rst:1530 msgid "" "Release a lock. This can be called from any process or thread, not only the " "process or thread which originally acquired the lock." msgstr "" -#: ../../library/multiprocessing.rst:1532 +#: ../../library/multiprocessing.rst:1533 msgid "" "Behavior is the same as in :meth:`threading.Lock.release` except that when " "invoked on an unlocked lock, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:1545 +#: ../../library/multiprocessing.rst:1546 msgid "" "A recursive lock object: a close analog of :class:`threading.RLock`. A " "recursive lock must be released by the process or thread that acquired it. " @@ -2272,20 +2273,20 @@ msgid "" "release it once for each time it has been acquired." msgstr "" -#: ../../library/multiprocessing.rst:1551 +#: ../../library/multiprocessing.rst:1552 msgid "" "Note that :class:`RLock` is actually a factory function which returns an " "instance of ``multiprocessing.synchronize.RLock`` initialized with a default " "context." msgstr "" -#: ../../library/multiprocessing.rst:1558 +#: ../../library/multiprocessing.rst:1559 msgid "" ":class:`RLock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1566 +#: ../../library/multiprocessing.rst:1567 msgid "" "When invoked with the *block* argument set to ``True``, block until the lock " "is in an unlocked state (not owned by any process or thread) unless the lock " @@ -2298,7 +2299,7 @@ msgid "" "itself." msgstr "" -#: ../../library/multiprocessing.rst:1576 +#: ../../library/multiprocessing.rst:1577 msgid "" "When invoked with the *block* argument set to ``False``, do not block. If " "the lock has already been acquired (and thus is owned) by another process or " @@ -2309,14 +2310,14 @@ msgid "" "a return value of ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1584 +#: ../../library/multiprocessing.rst:1585 msgid "" "Use and behaviors of the *timeout* argument are the same as in :meth:`Lock." "acquire`. Note that some of these behaviors of *timeout* differ from the " "implemented behaviors in :meth:`threading.RLock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1591 +#: ../../library/multiprocessing.rst:1592 msgid "" "Release a lock, decrementing the recursion level. If after the decrement " "the recursion level is zero, reset the lock to unlocked (not owned by any " @@ -2326,7 +2327,7 @@ msgid "" "locked and owned by the calling process or thread." msgstr "" -#: ../../library/multiprocessing.rst:1599 +#: ../../library/multiprocessing.rst:1600 msgid "" "Only call this method when the calling process or thread owns the lock. An :" "exc:`AssertionError` is raised if this method is called by a process or " @@ -2335,21 +2336,21 @@ msgid "" "from the implemented behavior in :meth:`threading.RLock.release`." msgstr "" -#: ../../library/multiprocessing.rst:1615 +#: ../../library/multiprocessing.rst:1616 msgid "A semaphore object: a close analog of :class:`threading.Semaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1626 +#: ../../library/multiprocessing.rst:1627 msgid "Return the current value of semaphore." msgstr "" -#: ../../library/multiprocessing.rst:1641 +#: ../../library/multiprocessing.rst:1642 msgid "" "On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with a " "timeout will emulate that function's behavior using a sleeping loop." msgstr "" -#: ../../library/multiprocessing.rst:1646 +#: ../../library/multiprocessing.rst:1647 msgid "" "Some of this package's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the :mod:" @@ -2358,32 +2359,32 @@ msgid "" "additional information." msgstr "" -#: ../../library/multiprocessing.rst:1654 +#: ../../library/multiprocessing.rst:1655 msgid "Shared :mod:`ctypes` Objects" msgstr "共享的 :mod:`ctypes` 物件" -#: ../../library/multiprocessing.rst:1656 +#: ../../library/multiprocessing.rst:1657 msgid "" "It is possible to create shared objects using shared memory which can be " "inherited by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1661 +#: ../../library/multiprocessing.rst:1662 msgid "" "Return a :mod:`ctypes` object allocated from shared memory. By default the " "return value is actually a synchronized wrapper for the object. The object " "itself can be accessed via the *value* attribute of a :class:`Value`." msgstr "" -#: ../../library/multiprocessing.rst:1665 -#: ../../library/multiprocessing.rst:1755 +#: ../../library/multiprocessing.rst:1666 +#: ../../library/multiprocessing.rst:1756 msgid "" "*typecode_or_type* determines the type of the returned object: it is either " "a ctypes type or a one character typecode of the kind used by the :mod:" "`array` module. *\\*args* is passed on to the constructor for the type." msgstr "" -#: ../../library/multiprocessing.rst:1669 +#: ../../library/multiprocessing.rst:1670 msgid "" "If *lock* is ``True`` (the default) then a new recursive lock object is " "created to synchronize access to the value. If *lock* is a :class:`Lock` " @@ -2393,24 +2394,24 @@ msgid "" "\"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1676 +#: ../../library/multiprocessing.rst:1677 msgid "" "Operations like ``+=`` which involve a read and write are not atomic. So " "if, for instance, you want to atomically increment a shared value it is " "insufficient to just do ::" msgstr "" -#: ../../library/multiprocessing.rst:1680 +#: ../../library/multiprocessing.rst:1681 msgid "counter.value += 1" msgstr "counter.value += 1" -#: ../../library/multiprocessing.rst:1682 +#: ../../library/multiprocessing.rst:1683 msgid "" "Assuming the associated lock is recursive (which it is by default) you can " "instead do ::" msgstr "" -#: ../../library/multiprocessing.rst:1685 +#: ../../library/multiprocessing.rst:1686 msgid "" "with counter.get_lock():\n" " counter.value += 1" @@ -2418,17 +2419,17 @@ msgstr "" "with counter.get_lock():\n" " counter.value += 1" -#: ../../library/multiprocessing.rst:1688 +#: ../../library/multiprocessing.rst:1689 msgid "Note that *lock* is a keyword-only argument." msgstr "" -#: ../../library/multiprocessing.rst:1692 +#: ../../library/multiprocessing.rst:1693 msgid "" "Return a ctypes array allocated from shared memory. By default the return " "value is actually a synchronized wrapper for the array." msgstr "" -#: ../../library/multiprocessing.rst:1695 +#: ../../library/multiprocessing.rst:1696 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a :ref:`ctypes type ` or " @@ -2441,7 +2442,7 @@ msgid "" "of the array." msgstr "" -#: ../../library/multiprocessing.rst:1705 +#: ../../library/multiprocessing.rst:1706 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`Lock` or :class:" @@ -2451,28 +2452,28 @@ msgid "" "safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1712 +#: ../../library/multiprocessing.rst:1713 msgid "Note that *lock* is a keyword only argument." msgstr "" -#: ../../library/multiprocessing.rst:1714 +#: ../../library/multiprocessing.rst:1715 msgid "" "Note that an array of :data:`ctypes.c_char` has *value* and *raw* attributes " "which allow one to use it to store and retrieve strings." msgstr "" -#: ../../library/multiprocessing.rst:1719 +#: ../../library/multiprocessing.rst:1720 msgid "The :mod:`!multiprocessing.sharedctypes` module" msgstr ":mod:`!multiprocessing.sharedctypes` 模組" -#: ../../library/multiprocessing.rst:1724 +#: ../../library/multiprocessing.rst:1725 msgid "" "The :mod:`!multiprocessing.sharedctypes` module provides functions for " "allocating :mod:`ctypes` objects from shared memory which can be inherited " "by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1730 +#: ../../library/multiprocessing.rst:1731 msgid "" "Although it is possible to store a pointer in shared memory remember that " "this will refer to a location in the address space of a specific process. " @@ -2481,11 +2482,11 @@ msgid "" "may cause a crash." msgstr "" -#: ../../library/multiprocessing.rst:1738 +#: ../../library/multiprocessing.rst:1739 msgid "Return a ctypes array allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1740 +#: ../../library/multiprocessing.rst:1741 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a ctypes type or a one character typecode of the kind " @@ -2495,40 +2496,40 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1747 +#: ../../library/multiprocessing.rst:1748 msgid "" "Note that setting and getting an element is potentially non-atomic -- use :" "func:`Array` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1753 +#: ../../library/multiprocessing.rst:1754 msgid "Return a ctypes object allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1759 +#: ../../library/multiprocessing.rst:1760 msgid "" "Note that setting and getting the value is potentially non-atomic -- use :" "func:`Value` instead to make sure that access is automatically synchronized " "using a lock." msgstr "" -#: ../../library/multiprocessing.rst:1763 +#: ../../library/multiprocessing.rst:1764 msgid "" "Note that an array of :data:`ctypes.c_char` has ``value`` and ``raw`` " "attributes which allow one to use it to store and retrieve strings -- see " "documentation for :mod:`ctypes`." msgstr "" -#: ../../library/multiprocessing.rst:1769 +#: ../../library/multiprocessing.rst:1770 msgid "" "The same as :func:`RawArray` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "array." msgstr "" -#: ../../library/multiprocessing.rst:1773 -#: ../../library/multiprocessing.rst:1793 +#: ../../library/multiprocessing.rst:1774 +#: ../../library/multiprocessing.rst:1794 msgid "" "If *lock* is ``True`` (the default) then a new lock object is created to " "synchronize access to the value. If *lock* is a :class:`~multiprocessing." @@ -2538,128 +2539,128 @@ msgid "" "not necessarily be \"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1781 -#: ../../library/multiprocessing.rst:1800 -#: ../../library/multiprocessing.rst:1817 -#: ../../library/multiprocessing.rst:1938 +#: ../../library/multiprocessing.rst:1782 +#: ../../library/multiprocessing.rst:1801 +#: ../../library/multiprocessing.rst:1818 +#: ../../library/multiprocessing.rst:1939 msgid "" "*ctx* is a context object, or ``None`` (use the current context). If " "``None``, calling this may set the global start method. See :ref:`global-" "start-method` for more details." msgstr "" -#: ../../library/multiprocessing.rst:1785 -#: ../../library/multiprocessing.rst:1804 +#: ../../library/multiprocessing.rst:1786 +#: ../../library/multiprocessing.rst:1805 msgid "Note that *lock* and *ctx* are keyword-only parameters." msgstr "" -#: ../../library/multiprocessing.rst:1789 +#: ../../library/multiprocessing.rst:1790 msgid "" "The same as :func:`RawValue` except that depending on the value of *lock* a " "process-safe synchronization wrapper may be returned instead of a raw ctypes " "object." msgstr "" -#: ../../library/multiprocessing.rst:1808 +#: ../../library/multiprocessing.rst:1809 msgid "" "Return a ctypes object allocated from shared memory which is a copy of the " "ctypes object *obj*." msgstr "" -#: ../../library/multiprocessing.rst:1813 +#: ../../library/multiprocessing.rst:1814 msgid "" "Return a process-safe wrapper object for a ctypes object which uses *lock* " "to synchronize access. If *lock* is ``None`` (the default) then a :class:" "`multiprocessing.RLock` object is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:1821 +#: ../../library/multiprocessing.rst:1822 msgid "" "A synchronized wrapper will have two methods in addition to those of the " "object it wraps: :meth:`get_obj` returns the wrapped object and :meth:" "`get_lock` returns the lock object used for synchronization." msgstr "" -#: ../../library/multiprocessing.rst:1825 +#: ../../library/multiprocessing.rst:1826 msgid "" "Note that accessing the ctypes object through the wrapper can be a lot " "slower than accessing the raw ctypes object." msgstr "" -#: ../../library/multiprocessing.rst:1828 +#: ../../library/multiprocessing.rst:1829 msgid "Synchronized objects support the :term:`context manager` protocol." msgstr "" -#: ../../library/multiprocessing.rst:1832 +#: ../../library/multiprocessing.rst:1833 msgid "" "The table below compares the syntax for creating shared ctypes objects from " "shared memory with the normal ctypes syntax. (In the table ``MyStruct`` is " "some subclass of :class:`ctypes.Structure`.)" msgstr "" -#: ../../library/multiprocessing.rst:1837 +#: ../../library/multiprocessing.rst:1838 msgid "ctypes" msgstr "ctypes" -#: ../../library/multiprocessing.rst:1837 +#: ../../library/multiprocessing.rst:1838 msgid "sharedctypes using type" msgstr "" -#: ../../library/multiprocessing.rst:1837 +#: ../../library/multiprocessing.rst:1838 msgid "sharedctypes using typecode" msgstr "" -#: ../../library/multiprocessing.rst:1839 +#: ../../library/multiprocessing.rst:1840 msgid "c_double(2.4)" msgstr "c_double(2.4)" -#: ../../library/multiprocessing.rst:1839 +#: ../../library/multiprocessing.rst:1840 msgid "RawValue(c_double, 2.4)" msgstr "RawValue(c_double, 2.4)" -#: ../../library/multiprocessing.rst:1839 +#: ../../library/multiprocessing.rst:1840 msgid "RawValue('d', 2.4)" msgstr "RawValue('d', 2.4)" -#: ../../library/multiprocessing.rst:1840 +#: ../../library/multiprocessing.rst:1841 msgid "MyStruct(4, 6)" msgstr "MyStruct(4, 6)" -#: ../../library/multiprocessing.rst:1840 +#: ../../library/multiprocessing.rst:1841 msgid "RawValue(MyStruct, 4, 6)" msgstr "RawValue(MyStruct, 4, 6)" -#: ../../library/multiprocessing.rst:1841 +#: ../../library/multiprocessing.rst:1842 msgid "(c_short * 7)()" msgstr "(c_short * 7)()" -#: ../../library/multiprocessing.rst:1841 +#: ../../library/multiprocessing.rst:1842 msgid "RawArray(c_short, 7)" msgstr "RawArray(c_short, 7)" -#: ../../library/multiprocessing.rst:1841 +#: ../../library/multiprocessing.rst:1842 msgid "RawArray('h', 7)" msgstr "RawArray('h', 7)" -#: ../../library/multiprocessing.rst:1842 +#: ../../library/multiprocessing.rst:1843 msgid "(c_int * 3)(9, 2, 8)" msgstr "(c_int * 3)(9, 2, 8)" -#: ../../library/multiprocessing.rst:1842 +#: ../../library/multiprocessing.rst:1843 msgid "RawArray(c_int, (9, 2, 8))" msgstr "RawArray(c_int, (9, 2, 8))" -#: ../../library/multiprocessing.rst:1842 +#: ../../library/multiprocessing.rst:1843 msgid "RawArray('i', (9, 2, 8))" msgstr "RawArray('i', (9, 2, 8))" -#: ../../library/multiprocessing.rst:1846 +#: ../../library/multiprocessing.rst:1847 msgid "" "Below is an example where a number of ctypes objects are modified by a child " "process::" msgstr "" -#: ../../library/multiprocessing.rst:1849 +#: ../../library/multiprocessing.rst:1850 msgid "" "from multiprocessing import Process, Lock\n" "from multiprocessing.sharedctypes import Value, Array\n" @@ -2725,11 +2726,11 @@ msgstr "" " print(s.value)\n" " print([(a.x, a.y) for a in A])" -#: ../../library/multiprocessing.rst:1884 +#: ../../library/multiprocessing.rst:1885 msgid "The results printed are ::" msgstr "" -#: ../../library/multiprocessing.rst:1886 +#: ../../library/multiprocessing.rst:1887 msgid "" "49\n" "0.1111111111111111\n" @@ -2741,11 +2742,11 @@ msgstr "" "HELLO WORLD\n" "[(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]" -#: ../../library/multiprocessing.rst:1897 +#: ../../library/multiprocessing.rst:1898 msgid "Managers" msgstr "" -#: ../../library/multiprocessing.rst:1899 +#: ../../library/multiprocessing.rst:1900 msgid "" "Managers provide a way to create data which can be shared between different " "processes, including sharing over a network between processes running on " @@ -2754,7 +2755,7 @@ msgid "" "proxies." msgstr "" -#: ../../library/multiprocessing.rst:1908 +#: ../../library/multiprocessing.rst:1909 msgid "" "Returns a started :class:`~multiprocessing.managers.SyncManager` object " "which can be used for sharing objects between processes. The returned " @@ -2762,31 +2763,31 @@ msgid "" "will create shared objects and return corresponding proxies." msgstr "" -#: ../../library/multiprocessing.rst:1916 +#: ../../library/multiprocessing.rst:1917 msgid "" "Manager processes will be shutdown as soon as they are garbage collected or " "their parent process exits. The manager classes are defined in the :mod:" "`multiprocessing.managers` module:" msgstr "" -#: ../../library/multiprocessing.rst:1922 +#: ../../library/multiprocessing.rst:1923 msgid "Create a BaseManager object." msgstr "建立一個 BaseManager 物件。" -#: ../../library/multiprocessing.rst:1924 +#: ../../library/multiprocessing.rst:1925 msgid "" "Once created one should call :meth:`start` or ``get_server()." "serve_forever()`` to ensure that the manager object refers to a started " "manager process." msgstr "" -#: ../../library/multiprocessing.rst:1927 +#: ../../library/multiprocessing.rst:1928 msgid "" "*address* is the address on which the manager process listens for new " "connections. If *address* is ``None`` then an arbitrary one is chosen." msgstr "" -#: ../../library/multiprocessing.rst:1930 +#: ../../library/multiprocessing.rst:1931 msgid "" "*authkey* is the authentication key which will be used to check the validity " "of incoming connections to the server process. If *authkey* is ``None`` " @@ -2794,13 +2795,13 @@ msgid "" "it must be a byte string." msgstr "" -#: ../../library/multiprocessing.rst:1935 +#: ../../library/multiprocessing.rst:1936 msgid "" "*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or " "``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization)." msgstr "" -#: ../../library/multiprocessing.rst:1942 +#: ../../library/multiprocessing.rst:1943 msgid "" "*shutdown_timeout* is a timeout in seconds used to wait until the process " "used by the manager completes in the :meth:`shutdown` method. If the " @@ -2808,24 +2809,24 @@ msgid "" "also times out, the process is killed." msgstr "" -#: ../../library/multiprocessing.rst:1947 +#: ../../library/multiprocessing.rst:1948 msgid "Added the *shutdown_timeout* parameter." msgstr "新增 *shutdown_timeout* 參數。" -#: ../../library/multiprocessing.rst:1952 +#: ../../library/multiprocessing.rst:1953 msgid "" "Start a subprocess to start the manager. If *initializer* is not ``None`` " "then the subprocess will call ``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:1957 +#: ../../library/multiprocessing.rst:1958 msgid "" "Returns a :class:`Server` object which represents the actual server under " "the control of the Manager. The :class:`Server` object supports the :meth:" "`serve_forever` method::" msgstr "" -#: ../../library/multiprocessing.rst:1961 +#: ../../library/multiprocessing.rst:1962 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> manager = BaseManager(address=('', 50000), authkey=b'abc')\n" @@ -2837,15 +2838,15 @@ msgstr "" ">>> server = manager.get_server()\n" ">>> server.serve_forever()" -#: ../../library/multiprocessing.rst:1966 +#: ../../library/multiprocessing.rst:1967 msgid ":class:`Server` additionally has an :attr:`address` attribute." msgstr "" -#: ../../library/multiprocessing.rst:1970 +#: ../../library/multiprocessing.rst:1971 msgid "Connect a local manager object to a remote manager process::" msgstr "" -#: ../../library/multiprocessing.rst:1972 +#: ../../library/multiprocessing.rst:1973 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" @@ -2855,29 +2856,29 @@ msgstr "" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" ">>> m.connect()" -#: ../../library/multiprocessing.rst:1978 +#: ../../library/multiprocessing.rst:1979 msgid "" "Stop the process used by the manager. This is only available if :meth:" "`start` has been used to start the server process." msgstr "" -#: ../../library/multiprocessing.rst:1981 +#: ../../library/multiprocessing.rst:1982 msgid "This can be called multiple times." msgstr "" -#: ../../library/multiprocessing.rst:1985 +#: ../../library/multiprocessing.rst:1986 msgid "" "A classmethod which can be used for registering a type or callable with the " "manager class." msgstr "" -#: ../../library/multiprocessing.rst:1988 +#: ../../library/multiprocessing.rst:1989 msgid "" "*typeid* is a \"type identifier\" which is used to identify a particular " "type of shared object. This must be a string." msgstr "" -#: ../../library/multiprocessing.rst:1991 +#: ../../library/multiprocessing.rst:1992 msgid "" "*callable* is a callable used for creating objects for this type " "identifier. If a manager instance will be connected to the server using " @@ -2885,14 +2886,14 @@ msgid "" "then this can be left as ``None``." msgstr "" -#: ../../library/multiprocessing.rst:1997 +#: ../../library/multiprocessing.rst:1998 msgid "" "*proxytype* is a subclass of :class:`BaseProxy` which is used to create " "proxies for shared objects with this *typeid*. If ``None`` then a proxy " "class is created automatically." msgstr "" -#: ../../library/multiprocessing.rst:2001 +#: ../../library/multiprocessing.rst:2002 msgid "" "*exposed* is used to specify a sequence of method names which proxies for " "this typeid should be allowed to access using :meth:`BaseProxy." @@ -2903,7 +2904,7 @@ msgid "" "method and whose name does not begin with ``'_'``.)" msgstr "" -#: ../../library/multiprocessing.rst:2010 +#: ../../library/multiprocessing.rst:2011 msgid "" "*method_to_typeid* is a mapping used to specify the return type of those " "exposed methods which should return a proxy. It maps method names to typeid " @@ -2913,22 +2914,22 @@ msgid "" "returned by the method will be copied by value." msgstr "" -#: ../../library/multiprocessing.rst:2017 +#: ../../library/multiprocessing.rst:2018 msgid "" "*create_method* determines whether a method should be created with name " "*typeid* which can be used to tell the server process to create a new shared " "object and return a proxy for it. By default it is ``True``." msgstr "" -#: ../../library/multiprocessing.rst:2021 +#: ../../library/multiprocessing.rst:2022 msgid ":class:`BaseManager` instances also have one read-only property:" msgstr "" -#: ../../library/multiprocessing.rst:2025 +#: ../../library/multiprocessing.rst:2026 msgid "The address used by the manager." msgstr "" -#: ../../library/multiprocessing.rst:2027 +#: ../../library/multiprocessing.rst:2028 msgid "" "Manager objects support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` starts the server " @@ -2936,129 +2937,129 @@ msgid "" "object. :meth:`~contextmanager.__exit__` calls :meth:`shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:2033 +#: ../../library/multiprocessing.rst:2034 msgid "" "In previous versions :meth:`~contextmanager.__enter__` did not start the " "manager's server process if it was not already started." msgstr "" -#: ../../library/multiprocessing.rst:2038 +#: ../../library/multiprocessing.rst:2039 msgid "" "A subclass of :class:`BaseManager` which can be used for the synchronization " "of processes. Objects of this type are returned by :func:`multiprocessing." "Manager`." msgstr "" -#: ../../library/multiprocessing.rst:2042 +#: ../../library/multiprocessing.rst:2043 msgid "" "Its methods create and return :ref:`multiprocessing-proxy_objects` for a " "number of commonly used data types to be synchronized across processes. This " "notably includes shared lists and dictionaries." msgstr "" -#: ../../library/multiprocessing.rst:2048 +#: ../../library/multiprocessing.rst:2049 msgid "" "Create a shared :class:`threading.Barrier` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2055 +#: ../../library/multiprocessing.rst:2056 msgid "" "Create a shared :class:`threading.BoundedSemaphore` object and return a " "proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2060 +#: ../../library/multiprocessing.rst:2061 msgid "" "Create a shared :class:`threading.Condition` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:2063 +#: ../../library/multiprocessing.rst:2064 msgid "" "If *lock* is supplied then it should be a proxy for a :class:`threading." "Lock` or :class:`threading.RLock` object." msgstr "" -#: ../../library/multiprocessing.rst:2071 +#: ../../library/multiprocessing.rst:2072 msgid "" "Create a shared :class:`threading.Event` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2075 +#: ../../library/multiprocessing.rst:2076 msgid "" "Create a shared :class:`threading.Lock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2079 +#: ../../library/multiprocessing.rst:2080 msgid "Create a shared :class:`Namespace` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2083 +#: ../../library/multiprocessing.rst:2084 msgid "Create a shared :class:`queue.Queue` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2087 +#: ../../library/multiprocessing.rst:2088 msgid "" "Create a shared :class:`threading.RLock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2091 +#: ../../library/multiprocessing.rst:2092 msgid "" "Create a shared :class:`threading.Semaphore` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:2096 +#: ../../library/multiprocessing.rst:2097 msgid "Create an array and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2100 +#: ../../library/multiprocessing.rst:2101 msgid "" "Create an object with a writable ``value`` attribute and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:2107 +#: ../../library/multiprocessing.rst:2108 msgid "Create a shared :class:`dict` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2112 +#: ../../library/multiprocessing.rst:2113 msgid "Create a shared :class:`list` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2118 +#: ../../library/multiprocessing.rst:2119 msgid "Create a shared :class:`set` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2120 +#: ../../library/multiprocessing.rst:2121 msgid ":class:`set` support was added." msgstr "已新增對 :class:`set` 的支援。" -#: ../../library/multiprocessing.rst:2123 +#: ../../library/multiprocessing.rst:2124 msgid "" "Shared objects are capable of being nested. For example, a shared container " "object such as a shared list can contain other shared objects which will all " "be managed and synchronized by the :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:2130 +#: ../../library/multiprocessing.rst:2131 msgid "A type that can register with :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:2132 +#: ../../library/multiprocessing.rst:2133 msgid "" "A namespace object has no public methods, but does have writable attributes. " "Its representation shows the values of its attributes." msgstr "" -#: ../../library/multiprocessing.rst:2135 +#: ../../library/multiprocessing.rst:2136 msgid "" "However, when using a proxy for a namespace object, an attribute beginning " "with ``'_'`` will be an attribute of the proxy and not an attribute of the " "referent:" msgstr "" -#: ../../library/multiprocessing.rst:2139 +#: ../../library/multiprocessing.rst:2140 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3070,18 +3071,18 @@ msgid "" "Namespace(x=10, y='hello')" msgstr "" -#: ../../library/multiprocessing.rst:2152 +#: ../../library/multiprocessing.rst:2153 msgid "Customized managers" msgstr "" -#: ../../library/multiprocessing.rst:2154 +#: ../../library/multiprocessing.rst:2155 msgid "" "To create one's own manager, one creates a subclass of :class:`BaseManager` " "and uses the :meth:`~BaseManager.register` classmethod to register new types " "or callables with the manager class. For example::" msgstr "" -#: ../../library/multiprocessing.rst:2158 +#: ../../library/multiprocessing.rst:2159 msgid "" "from multiprocessing.managers import BaseManager\n" "\n" @@ -3121,23 +3122,23 @@ msgstr "" " print(maths.add(4, 3)) # 印出 7\n" " print(maths.mul(7, 8)) # 印出 56" -#: ../../library/multiprocessing.rst:2179 +#: ../../library/multiprocessing.rst:2180 msgid "Using a remote manager" msgstr "" -#: ../../library/multiprocessing.rst:2181 +#: ../../library/multiprocessing.rst:2182 msgid "" "It is possible to run a manager server on one machine and have clients use " "it from other machines (assuming that the firewalls involved allow it)." msgstr "" -#: ../../library/multiprocessing.rst:2184 +#: ../../library/multiprocessing.rst:2185 msgid "" "Running the following commands creates a server for a single shared queue " "which remote clients can access::" msgstr "" -#: ../../library/multiprocessing.rst:2187 +#: ../../library/multiprocessing.rst:2188 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> from queue import Queue\n" @@ -3157,11 +3158,11 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2196 +#: ../../library/multiprocessing.rst:2197 msgid "One client can access the server as follows::" msgstr "" -#: ../../library/multiprocessing.rst:2198 +#: ../../library/multiprocessing.rst:2199 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3181,11 +3182,11 @@ msgstr "" ">>> queue = m.get_queue()\n" ">>> queue.put('hello')" -#: ../../library/multiprocessing.rst:2206 +#: ../../library/multiprocessing.rst:2207 msgid "Another client can also use it::" msgstr "" -#: ../../library/multiprocessing.rst:2208 +#: ../../library/multiprocessing.rst:2209 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3207,13 +3208,13 @@ msgstr "" ">>> queue.get()\n" "'hello'" -#: ../../library/multiprocessing.rst:2217 +#: ../../library/multiprocessing.rst:2218 msgid "" "Local processes can also access that queue, using the code from above on the " "client to access it remotely::" msgstr "" -#: ../../library/multiprocessing.rst:2220 +#: ../../library/multiprocessing.rst:2221 msgid "" ">>> from multiprocessing import Process, Queue\n" ">>> from multiprocessing.managers import BaseManager\n" @@ -3253,18 +3254,18 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2242 +#: ../../library/multiprocessing.rst:2243 msgid "Proxy Objects" msgstr "" -#: ../../library/multiprocessing.rst:2244 +#: ../../library/multiprocessing.rst:2245 msgid "" "A proxy is an object which *refers* to a shared object which lives " "(presumably) in a different process. The shared object is said to be the " "*referent* of the proxy. Multiple proxy objects may have the same referent." msgstr "" -#: ../../library/multiprocessing.rst:2248 +#: ../../library/multiprocessing.rst:2249 msgid "" "A proxy object has methods which invoke corresponding methods of its " "referent (although not every method of the referent will necessarily be " @@ -3272,7 +3273,7 @@ msgid "" "its referent can:" msgstr "" -#: ../../library/multiprocessing.rst:2252 +#: ../../library/multiprocessing.rst:2253 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3298,14 +3299,14 @@ msgstr "" ">>> l[2:5]\n" "[4, 9, 16]" -#: ../../library/multiprocessing.rst:2266 +#: ../../library/multiprocessing.rst:2267 msgid "" "Notice that applying :func:`str` to a proxy will return the representation " "of the referent, whereas applying :func:`repr` will return the " "representation of the proxy." msgstr "" -#: ../../library/multiprocessing.rst:2270 +#: ../../library/multiprocessing.rst:2271 msgid "" "An important feature of proxy objects is that they are picklable so they can " "be passed between processes. As such, a referent can contain :ref:" @@ -3313,7 +3314,7 @@ msgid "" "lists, dicts, and other :ref:`multiprocessing-proxy_objects`:" msgstr "" -#: ../../library/multiprocessing.rst:2275 +#: ../../library/multiprocessing.rst:2276 msgid "" ">>> a = manager.list()\n" ">>> b = manager.list()\n" @@ -3325,11 +3326,11 @@ msgid "" "['hello'] ['hello']" msgstr "" -#: ../../library/multiprocessing.rst:2286 +#: ../../library/multiprocessing.rst:2287 msgid "Similarly, dict and list proxies may be nested inside one another::" msgstr "" -#: ../../library/multiprocessing.rst:2288 +#: ../../library/multiprocessing.rst:2289 msgid "" ">>> l_outer = manager.list([ manager.dict() for i in range(2) ])\n" ">>> d_first_inner = l_outer[0]\n" @@ -3353,7 +3354,7 @@ msgstr "" ">>> print(l_outer[1])\n" "{'c': 3, 'z': 26}" -#: ../../library/multiprocessing.rst:2299 +#: ../../library/multiprocessing.rst:2300 msgid "" "If standard (non-proxy) :class:`list` or :class:`dict` objects are contained " "in a referent, modifications to those mutable values will not be propagated " @@ -3364,7 +3365,7 @@ msgid "" "assign the modified value to the container proxy::" msgstr "" -#: ../../library/multiprocessing.rst:2307 +#: ../../library/multiprocessing.rst:2308 msgid "" "# create a list proxy and append a mutable object (a dictionary)\n" "lproxy = manager.list()\n" @@ -3378,20 +3379,20 @@ msgid "" "lproxy[0] = d" msgstr "" -#: ../../library/multiprocessing.rst:2318 +#: ../../library/multiprocessing.rst:2319 msgid "" "This approach is perhaps less convenient than employing nested :ref:" "`multiprocessing-proxy_objects` for most use cases but also demonstrates a " "level of control over the synchronization." msgstr "" -#: ../../library/multiprocessing.rst:2324 +#: ../../library/multiprocessing.rst:2325 msgid "" "The proxy types in :mod:`!multiprocessing` do nothing to support comparisons " "by value. So, for instance, we have:" msgstr "" -#: ../../library/multiprocessing.rst:2327 +#: ../../library/multiprocessing.rst:2328 msgid "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" @@ -3399,48 +3400,48 @@ msgstr "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" -#: ../../library/multiprocessing.rst:2332 +#: ../../library/multiprocessing.rst:2333 msgid "" "One should just use a copy of the referent instead when making comparisons." msgstr "" -#: ../../library/multiprocessing.rst:2336 +#: ../../library/multiprocessing.rst:2337 msgid "Proxy objects are instances of subclasses of :class:`BaseProxy`." msgstr "" -#: ../../library/multiprocessing.rst:2340 +#: ../../library/multiprocessing.rst:2341 msgid "Call and return the result of a method of the proxy's referent." msgstr "" -#: ../../library/multiprocessing.rst:2342 +#: ../../library/multiprocessing.rst:2343 msgid "" "If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2344 +#: ../../library/multiprocessing.rst:2345 msgid "proxy._callmethod(methodname, args, kwds)" msgstr "proxy._callmethod(methodname, args, kwds)" -#: ../../library/multiprocessing.rst:2346 +#: ../../library/multiprocessing.rst:2347 msgid "will evaluate the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2348 +#: ../../library/multiprocessing.rst:2349 msgid "getattr(obj, methodname)(*args, **kwds)" msgstr "getattr(obj, methodname)(*args, **kwds)" -#: ../../library/multiprocessing.rst:2350 +#: ../../library/multiprocessing.rst:2351 msgid "in the manager's process." msgstr "" -#: ../../library/multiprocessing.rst:2352 +#: ../../library/multiprocessing.rst:2353 msgid "" "The returned value will be a copy of the result of the call or a proxy to a " "new shared object -- see documentation for the *method_to_typeid* argument " "of :meth:`BaseManager.register`." msgstr "" -#: ../../library/multiprocessing.rst:2356 +#: ../../library/multiprocessing.rst:2357 msgid "" "If an exception is raised by the call, then is re-raised by :meth:" "`_callmethod`. If some other exception is raised in the manager's process " @@ -3448,17 +3449,17 @@ msgid "" "meth:`_callmethod`." msgstr "" -#: ../../library/multiprocessing.rst:2361 +#: ../../library/multiprocessing.rst:2362 msgid "" "Note in particular that an exception will be raised if *methodname* has not " "been *exposed*." msgstr "" -#: ../../library/multiprocessing.rst:2364 +#: ../../library/multiprocessing.rst:2365 msgid "An example of the usage of :meth:`_callmethod`:" msgstr "" -#: ../../library/multiprocessing.rst:2366 +#: ../../library/multiprocessing.rst:2367 msgid "" ">>> l = manager.list(range(10))\n" ">>> l._callmethod('__len__')\n" @@ -3480,69 +3481,69 @@ msgstr "" "...\n" "IndexError: list index out of range" -#: ../../library/multiprocessing.rst:2380 +#: ../../library/multiprocessing.rst:2381 msgid "Return a copy of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2382 +#: ../../library/multiprocessing.rst:2383 msgid "If the referent is unpicklable then this will raise an exception." msgstr "" -#: ../../library/multiprocessing.rst:2386 +#: ../../library/multiprocessing.rst:2387 msgid "Return a representation of the proxy object." msgstr "" -#: ../../library/multiprocessing.rst:2390 +#: ../../library/multiprocessing.rst:2391 msgid "Return the representation of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2394 +#: ../../library/multiprocessing.rst:2395 msgid "Cleanup" msgstr "" -#: ../../library/multiprocessing.rst:2396 +#: ../../library/multiprocessing.rst:2397 msgid "" "A proxy object uses a weakref callback so that when it gets garbage " "collected it deregisters itself from the manager which owns its referent." msgstr "" -#: ../../library/multiprocessing.rst:2399 +#: ../../library/multiprocessing.rst:2400 msgid "" "A shared object gets deleted from the manager process when there are no " "longer any proxies referring to it." msgstr "" -#: ../../library/multiprocessing.rst:2404 +#: ../../library/multiprocessing.rst:2405 msgid "Process Pools" msgstr "" -#: ../../library/multiprocessing.rst:2409 +#: ../../library/multiprocessing.rst:2410 msgid "" "One can create a pool of processes which will carry out tasks submitted to " "it with the :class:`Pool` class." msgstr "" -#: ../../library/multiprocessing.rst:2414 +#: ../../library/multiprocessing.rst:2415 msgid "" "A process pool object which controls a pool of worker processes to which " "jobs can be submitted. It supports asynchronous results with timeouts and " "callbacks and has a parallel map implementation." msgstr "" -#: ../../library/multiprocessing.rst:2418 +#: ../../library/multiprocessing.rst:2419 msgid "" "*processes* is the number of worker processes to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2421 -#: ../../library/multiprocessing.rst:2987 +#: ../../library/multiprocessing.rst:2422 +#: ../../library/multiprocessing.rst:2988 msgid "" "If *initializer* is not ``None`` then each worker process will call " "``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:2424 +#: ../../library/multiprocessing.rst:2425 msgid "" "*maxtasksperchild* is the number of tasks a worker process can complete " "before it will exit and be replaced with a fresh worker process, to enable " @@ -3550,7 +3551,7 @@ msgid "" "which means worker processes will live as long as the pool." msgstr "" -#: ../../library/multiprocessing.rst:2429 +#: ../../library/multiprocessing.rst:2430 msgid "" "*context* can be used to specify the context used for starting the worker " "processes. Usually a pool is created using the function :func:" @@ -3560,13 +3561,13 @@ msgid "" "method if it has not been set already. See the :func:`get_context` function." msgstr "" -#: ../../library/multiprocessing.rst:2437 +#: ../../library/multiprocessing.rst:2438 msgid "" "Note that the methods of the pool object should only be called by the " "process which created the pool." msgstr "" -#: ../../library/multiprocessing.rst:2441 +#: ../../library/multiprocessing.rst:2442 msgid "" ":class:`multiprocessing.pool` objects have internal resources that need to " "be properly managed (like any other resource) by using the pool as a context " @@ -3574,28 +3575,28 @@ msgid "" "to do this can lead to the process hanging on finalization." msgstr "" -#: ../../library/multiprocessing.rst:2446 +#: ../../library/multiprocessing.rst:2447 msgid "" "Note that it is **not correct** to rely on the garbage collector to destroy " "the pool as CPython does not assure that the finalizer of the pool will be " "called (see :meth:`object.__del__` for more information)." msgstr "" -#: ../../library/multiprocessing.rst:2450 +#: ../../library/multiprocessing.rst:2451 msgid "Added the *maxtasksperchild* parameter." msgstr "新增 *maxtasksperchild* 參數。" -#: ../../library/multiprocessing.rst:2453 +#: ../../library/multiprocessing.rst:2454 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/multiprocessing.rst:2456 +#: ../../library/multiprocessing.rst:2457 msgid "" "*processes* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/multiprocessing.rst:2462 +#: ../../library/multiprocessing.rst:2463 msgid "" "Worker processes within a :class:`Pool` typically live for the complete " "duration of the Pool's work queue. A frequent pattern found in other systems " @@ -3606,7 +3607,7 @@ msgid "" "the end user." msgstr "" -#: ../../library/multiprocessing.rst:2472 +#: ../../library/multiprocessing.rst:2473 msgid "" "Call *func* with arguments *args* and keyword arguments *kwds*. It blocks " "until the result is ready. Given this blocks, :meth:`apply_async` is better " @@ -3614,14 +3615,14 @@ msgid "" "executed in one of the workers of the pool." msgstr "" -#: ../../library/multiprocessing.rst:2479 +#: ../../library/multiprocessing.rst:2480 msgid "" "A variant of the :meth:`apply` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2482 -#: ../../library/multiprocessing.rst:2513 +#: ../../library/multiprocessing.rst:2483 +#: ../../library/multiprocessing.rst:2514 msgid "" "If *callback* is specified then it should be a callable which accepts a " "single argument. When the result becomes ready *callback* is applied to it, " @@ -3629,60 +3630,60 @@ msgid "" "applied instead." msgstr "" -#: ../../library/multiprocessing.rst:2487 -#: ../../library/multiprocessing.rst:2518 +#: ../../library/multiprocessing.rst:2488 +#: ../../library/multiprocessing.rst:2519 msgid "" "If *error_callback* is specified then it should be a callable which accepts " "a single argument. If the target function fails, then the *error_callback* " "is called with the exception instance." msgstr "" -#: ../../library/multiprocessing.rst:2491 -#: ../../library/multiprocessing.rst:2522 +#: ../../library/multiprocessing.rst:2492 +#: ../../library/multiprocessing.rst:2523 msgid "" "Callbacks should complete immediately since otherwise the thread which " "handles the results will get blocked." msgstr "" -#: ../../library/multiprocessing.rst:2496 +#: ../../library/multiprocessing.rst:2497 msgid "" "A parallel equivalent of the :func:`map` built-in function (it supports only " "one *iterable* argument though, for multiple iterables see :meth:`starmap`). " "It blocks until the result is ready." msgstr "" -#: ../../library/multiprocessing.rst:2500 +#: ../../library/multiprocessing.rst:2501 msgid "" "This method chops the iterable into a number of chunks which it submits to " "the process pool as separate tasks. The (approximate) size of these chunks " "can be specified by setting *chunksize* to a positive integer." msgstr "" -#: ../../library/multiprocessing.rst:2504 +#: ../../library/multiprocessing.rst:2505 msgid "" "Note that it may cause high memory usage for very long iterables. Consider " "using :meth:`imap` or :meth:`imap_unordered` with explicit *chunksize* " "option for better efficiency." msgstr "" -#: ../../library/multiprocessing.rst:2510 +#: ../../library/multiprocessing.rst:2511 msgid "" "A variant of the :meth:`.map` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2527 +#: ../../library/multiprocessing.rst:2528 msgid "A lazier version of :meth:`.map`." msgstr "" -#: ../../library/multiprocessing.rst:2529 +#: ../../library/multiprocessing.rst:2530 msgid "" "The *chunksize* argument is the same as the one used by the :meth:`.map` " "method. For very long iterables using a large value for *chunksize* can " "make the job complete **much** faster than using the default value of ``1``." msgstr "" -#: ../../library/multiprocessing.rst:2534 +#: ../../library/multiprocessing.rst:2535 msgid "" "Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator " "returned by the :meth:`imap` method has an optional *timeout* parameter: " @@ -3690,65 +3691,65 @@ msgid "" "result cannot be returned within *timeout* seconds." msgstr "" -#: ../../library/multiprocessing.rst:2541 +#: ../../library/multiprocessing.rst:2542 msgid "" "The same as :meth:`imap` except that the ordering of the results from the " "returned iterator should be considered arbitrary. (Only when there is only " "one worker process is the order guaranteed to be \"correct\".)" msgstr "" -#: ../../library/multiprocessing.rst:2547 +#: ../../library/multiprocessing.rst:2548 msgid "" "Like :meth:`~multiprocessing.pool.Pool.map` except that the elements of the " "*iterable* are expected to be iterables that are unpacked as arguments." msgstr "" -#: ../../library/multiprocessing.rst:2551 +#: ../../library/multiprocessing.rst:2552 msgid "" "Hence an *iterable* of ``[(1,2), (3, 4)]`` results in ``[func(1,2), " "func(3,4)]``." msgstr "" -#: ../../library/multiprocessing.rst:2558 +#: ../../library/multiprocessing.rst:2559 msgid "" "A combination of :meth:`starmap` and :meth:`map_async` that iterates over " "*iterable* of iterables and calls *func* with the iterables unpacked. " "Returns a result object." msgstr "" -#: ../../library/multiprocessing.rst:2566 +#: ../../library/multiprocessing.rst:2567 msgid "" "Prevents any more tasks from being submitted to the pool. Once all the " "tasks have been completed the worker processes will exit." msgstr "" -#: ../../library/multiprocessing.rst:2571 +#: ../../library/multiprocessing.rst:2572 msgid "" "Stops the worker processes immediately without completing outstanding work. " "When the pool object is garbage collected :meth:`terminate` will be called " "immediately." msgstr "" -#: ../../library/multiprocessing.rst:2577 +#: ../../library/multiprocessing.rst:2578 msgid "" "Wait for the worker processes to exit. One must call :meth:`close` or :meth:" "`terminate` before using :meth:`join`." msgstr "" -#: ../../library/multiprocessing.rst:2580 +#: ../../library/multiprocessing.rst:2581 msgid "" "Pool objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the pool " "object, and :meth:`~contextmanager.__exit__` calls :meth:`terminate`." msgstr "" -#: ../../library/multiprocessing.rst:2588 +#: ../../library/multiprocessing.rst:2589 msgid "" "The class of the result returned by :meth:`Pool.apply_async` and :meth:`Pool." "map_async`." msgstr "" -#: ../../library/multiprocessing.rst:2593 +#: ../../library/multiprocessing.rst:2594 msgid "" "Return the result when it arrives. If *timeout* is not ``None`` and the " "result does not arrive within *timeout* seconds then :exc:`multiprocessing." @@ -3756,31 +3757,31 @@ msgid "" "exception will be reraised by :meth:`get`." msgstr "" -#: ../../library/multiprocessing.rst:2600 +#: ../../library/multiprocessing.rst:2601 msgid "Wait until the result is available or until *timeout* seconds pass." msgstr "" -#: ../../library/multiprocessing.rst:2604 +#: ../../library/multiprocessing.rst:2605 msgid "Return whether the call has completed." msgstr "" -#: ../../library/multiprocessing.rst:2608 +#: ../../library/multiprocessing.rst:2609 msgid "" "Return whether the call completed without raising an exception. Will raise :" "exc:`ValueError` if the result is not ready." msgstr "" -#: ../../library/multiprocessing.rst:2611 +#: ../../library/multiprocessing.rst:2612 msgid "" "If the result is not ready, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:2615 +#: ../../library/multiprocessing.rst:2616 msgid "The following example demonstrates the use of a pool::" msgstr "" -#: ../../library/multiprocessing.rst:2617 +#: ../../library/multiprocessing.rst:2618 msgid "" "from multiprocessing import Pool\n" "import time\n" @@ -3808,17 +3809,17 @@ msgid "" "TimeoutError" msgstr "" -#: ../../library/multiprocessing.rst:2642 +#: ../../library/multiprocessing.rst:2643 msgid "Listeners and Clients" msgstr "" -#: ../../library/multiprocessing.rst:2647 +#: ../../library/multiprocessing.rst:2648 msgid "" "Usually message passing between processes is done using queues or by using :" "class:`~Connection` objects returned by :func:`~multiprocessing.Pipe`." msgstr "" -#: ../../library/multiprocessing.rst:2651 +#: ../../library/multiprocessing.rst:2652 msgid "" "However, the :mod:`!multiprocessing.connection` module allows some extra " "flexibility. It basically gives a high level message oriented API for " @@ -3827,46 +3828,46 @@ msgid "" "multiple connections at the same time." msgstr "" -#: ../../library/multiprocessing.rst:2660 +#: ../../library/multiprocessing.rst:2661 msgid "" "Send a randomly generated message to the other end of the connection and " "wait for a reply." msgstr "" -#: ../../library/multiprocessing.rst:2663 +#: ../../library/multiprocessing.rst:2664 msgid "" "If the reply matches the digest of the message using *authkey* as the key " "then a welcome message is sent to the other end of the connection. " "Otherwise :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2669 +#: ../../library/multiprocessing.rst:2670 msgid "" "Receive a message, calculate the digest of the message using *authkey* as " "the key, and then send the digest back." msgstr "" -#: ../../library/multiprocessing.rst:2672 +#: ../../library/multiprocessing.rst:2673 msgid "" "If a welcome message is not received, then :exc:`~multiprocessing." "AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2677 +#: ../../library/multiprocessing.rst:2678 msgid "" "Attempt to set up a connection to the listener which is using address " "*address*, returning a :class:`~Connection`." msgstr "" -#: ../../library/multiprocessing.rst:2680 +#: ../../library/multiprocessing.rst:2681 msgid "" "The type of the connection is determined by *family* argument, but this can " "generally be omitted since it can usually be inferred from the format of " "*address*. (See :ref:`multiprocessing-address-formats`)" msgstr "" -#: ../../library/multiprocessing.rst:2684 -#: ../../library/multiprocessing.rst:2719 +#: ../../library/multiprocessing.rst:2685 +#: ../../library/multiprocessing.rst:2720 msgid "" "If *authkey* is given and not ``None``, it should be a byte string and will " "be used as the secret key for an HMAC-based authentication challenge. No " @@ -3875,26 +3876,26 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:2692 +#: ../../library/multiprocessing.rst:2693 msgid "" "A wrapper for a bound socket or Windows named pipe which is 'listening' for " "connections." msgstr "" -#: ../../library/multiprocessing.rst:2695 +#: ../../library/multiprocessing.rst:2696 msgid "" "*address* is the address to be used by the bound socket or named pipe of the " "listener object." msgstr "" -#: ../../library/multiprocessing.rst:2700 +#: ../../library/multiprocessing.rst:2701 msgid "" "If an address of '0.0.0.0' is used, the address will not be a connectable " "end point on Windows. If you require a connectable end-point, you should use " "'127.0.0.1'." msgstr "" -#: ../../library/multiprocessing.rst:2704 +#: ../../library/multiprocessing.rst:2705 msgid "" "*family* is the type of socket (or named pipe) to use. This can be one of " "the strings ``'AF_INET'`` (for a TCP socket), ``'AF_UNIX'`` (for a Unix " @@ -3908,49 +3909,49 @@ msgid "" "using :func:`tempfile.mkstemp`." msgstr "" -#: ../../library/multiprocessing.rst:2715 +#: ../../library/multiprocessing.rst:2716 msgid "" "If the listener object uses a socket then *backlog* (1 by default) is passed " "to the :meth:`~socket.socket.listen` method of the socket once it has been " "bound." msgstr "" -#: ../../library/multiprocessing.rst:2727 +#: ../../library/multiprocessing.rst:2728 msgid "" "Accept a connection on the bound socket or named pipe of the listener object " "and return a :class:`~Connection` object. If authentication is attempted and " "fails, then :exc:`~multiprocessing.AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2734 +#: ../../library/multiprocessing.rst:2735 msgid "" "Close the bound socket or named pipe of the listener object. This is called " "automatically when the listener is garbage collected. However it is " "advisable to call it explicitly." msgstr "" -#: ../../library/multiprocessing.rst:2738 +#: ../../library/multiprocessing.rst:2739 msgid "Listener objects have the following read-only properties:" msgstr "" -#: ../../library/multiprocessing.rst:2742 +#: ../../library/multiprocessing.rst:2743 msgid "The address which is being used by the Listener object." msgstr "" -#: ../../library/multiprocessing.rst:2746 +#: ../../library/multiprocessing.rst:2747 msgid "" "The address from which the last accepted connection came. If this is " "unavailable then it is ``None``." msgstr "" -#: ../../library/multiprocessing.rst:2749 +#: ../../library/multiprocessing.rst:2750 msgid "" "Listener objects now support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` returns the " "listener object, and :meth:`~contextmanager.__exit__` calls :meth:`close`." msgstr "" -#: ../../library/multiprocessing.rst:2756 +#: ../../library/multiprocessing.rst:2757 msgid "" "Wait till an object in *object_list* is ready. Returns the list of those " "objects in *object_list* which are ready. If *timeout* is a float then the " @@ -3959,32 +3960,32 @@ msgid "" "zero timeout." msgstr "" -#: ../../library/multiprocessing.rst:2762 +#: ../../library/multiprocessing.rst:2763 msgid "" "For both POSIX and Windows, an object can appear in *object_list* if it is" msgstr "" -#: ../../library/multiprocessing.rst:2765 +#: ../../library/multiprocessing.rst:2766 msgid "a readable :class:`~multiprocessing.connection.Connection` object;" msgstr "" -#: ../../library/multiprocessing.rst:2766 +#: ../../library/multiprocessing.rst:2767 msgid "a connected and readable :class:`socket.socket` object; or" msgstr "" -#: ../../library/multiprocessing.rst:2767 +#: ../../library/multiprocessing.rst:2768 msgid "" "the :attr:`~multiprocessing.Process.sentinel` attribute of a :class:" "`~multiprocessing.Process` object." msgstr "" -#: ../../library/multiprocessing.rst:2770 +#: ../../library/multiprocessing.rst:2771 msgid "" "A connection or socket object is ready when there is data available to be " "read from it, or the other end has been closed." msgstr "" -#: ../../library/multiprocessing.rst:2773 +#: ../../library/multiprocessing.rst:2774 msgid "" "**POSIX**: ``wait(object_list, timeout)`` almost equivalent ``select." "select(object_list, [], [], timeout)``. The difference is that, if :func:" @@ -3992,7 +3993,7 @@ msgid "" "an error number of ``EINTR``, whereas :func:`wait` will not." msgstr "" -#: ../../library/multiprocessing.rst:2779 +#: ../../library/multiprocessing.rst:2780 msgid "" "**Windows**: An item in *object_list* must either be an integer handle which " "is waitable (according to the definition used by the documentation of the " @@ -4002,18 +4003,18 @@ msgid "" "handles.)" msgstr "" -#: ../../library/multiprocessing.rst:2789 +#: ../../library/multiprocessing.rst:2790 msgid "**Examples**" msgstr "" -#: ../../library/multiprocessing.rst:2791 +#: ../../library/multiprocessing.rst:2792 msgid "" "The following server code creates a listener which uses ``'secret " "password'`` as an authentication key. It then waits for a connection and " "sends some data to the client::" msgstr "" -#: ../../library/multiprocessing.rst:2795 +#: ../../library/multiprocessing.rst:2796 msgid "" "from multiprocessing.connection import Listener\n" "from array import array\n" @@ -4031,13 +4032,13 @@ msgid "" " conn.send_bytes(array('i', [42, 1729]))" msgstr "" -#: ../../library/multiprocessing.rst:2810 +#: ../../library/multiprocessing.rst:2811 msgid "" "The following code connects to the server and receives some data from the " "server::" msgstr "" -#: ../../library/multiprocessing.rst:2813 +#: ../../library/multiprocessing.rst:2814 msgid "" "from multiprocessing.connection import Client\n" "from array import array\n" @@ -4067,13 +4068,13 @@ msgstr "" " print(conn.recv_bytes_into(arr)) # => 8\n" " print(arr) # => array('i', [42, 1729, 0, 0, 0])" -#: ../../library/multiprocessing.rst:2827 +#: ../../library/multiprocessing.rst:2828 msgid "" "The following code uses :func:`~multiprocessing.connection.wait` to wait for " "messages from multiple processes at once::" msgstr "" -#: ../../library/multiprocessing.rst:2830 +#: ../../library/multiprocessing.rst:2831 msgid "" "from multiprocessing import Process, Pipe, current_process\n" "from multiprocessing.connection import wait\n" @@ -4107,23 +4108,23 @@ msgid "" " print(msg)" msgstr "" -#: ../../library/multiprocessing.rst:2865 +#: ../../library/multiprocessing.rst:2866 msgid "Address Formats" msgstr "" -#: ../../library/multiprocessing.rst:2867 +#: ../../library/multiprocessing.rst:2868 msgid "" "An ``'AF_INET'`` address is a tuple of the form ``(hostname, port)`` where " "*hostname* is a string and *port* is an integer." msgstr "" -#: ../../library/multiprocessing.rst:2870 +#: ../../library/multiprocessing.rst:2871 msgid "" "An ``'AF_UNIX'`` address is a string representing a filename on the " "filesystem." msgstr "" -#: ../../library/multiprocessing.rst:2873 +#: ../../library/multiprocessing.rst:2874 msgid "" "An ``'AF_PIPE'`` address is a string of the form :samp:`r'\\\\\\\\\\\\.\\" "\\pipe\\\\\\\\{PipeName}'`. To use :func:`Client` to connect to a named " @@ -4132,17 +4133,17 @@ msgid "" "instead." msgstr "" -#: ../../library/multiprocessing.rst:2878 +#: ../../library/multiprocessing.rst:2879 msgid "" "Note that any string beginning with two backslashes is assumed by default to " "be an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address." msgstr "" -#: ../../library/multiprocessing.rst:2885 +#: ../../library/multiprocessing.rst:2886 msgid "Authentication keys" msgstr "" -#: ../../library/multiprocessing.rst:2887 +#: ../../library/multiprocessing.rst:2888 msgid "" "When one uses :meth:`Connection.recv `, the data received " "is automatically unpickled. Unfortunately unpickling data from an untrusted " @@ -4150,7 +4151,7 @@ msgid "" "use the :mod:`hmac` module to provide digest authentication." msgstr "" -#: ../../library/multiprocessing.rst:2893 +#: ../../library/multiprocessing.rst:2894 msgid "" "An authentication key is a byte string which can be thought of as a " "password: once a connection is established both ends will demand proof that " @@ -4158,7 +4159,7 @@ msgid "" "using the same key does **not** involve sending the key over the connection.)" msgstr "" -#: ../../library/multiprocessing.rst:2899 +#: ../../library/multiprocessing.rst:2900 msgid "" "If authentication is requested but no authentication key is specified then " "the return value of ``current_process().authkey`` is used (see :class:" @@ -4169,17 +4170,17 @@ msgid "" "setting up connections between themselves." msgstr "" -#: ../../library/multiprocessing.rst:2907 +#: ../../library/multiprocessing.rst:2908 msgid "" "Suitable authentication keys can also be generated by using :func:`os." "urandom`." msgstr "" -#: ../../library/multiprocessing.rst:2911 +#: ../../library/multiprocessing.rst:2912 msgid "Logging" msgstr "" -#: ../../library/multiprocessing.rst:2913 +#: ../../library/multiprocessing.rst:2914 msgid "" "Some support for logging is available. Note, however, that the :mod:" "`logging` package does not use process shared locks so it is possible " @@ -4187,27 +4188,27 @@ msgid "" "mixed up." msgstr "" -#: ../../library/multiprocessing.rst:2920 +#: ../../library/multiprocessing.rst:2921 msgid "" "Returns the logger used by :mod:`!multiprocessing`. If necessary, a new one " "will be created." msgstr "" -#: ../../library/multiprocessing.rst:2923 +#: ../../library/multiprocessing.rst:2924 msgid "" "When first created the logger has level :const:`logging.NOTSET` and no " "default handler. Messages sent to this logger will not by default propagate " "to the root logger." msgstr "" -#: ../../library/multiprocessing.rst:2927 +#: ../../library/multiprocessing.rst:2928 msgid "" "Note that on Windows child processes will only inherit the level of the " "parent process's logger -- any other customization of the logger will not be " "inherited." msgstr "" -#: ../../library/multiprocessing.rst:2934 +#: ../../library/multiprocessing.rst:2935 msgid "" "This function performs a call to :func:`get_logger` but in addition to " "returning the logger created by get_logger, it adds a handler which sends " @@ -4216,11 +4217,11 @@ msgid "" "``level`` argument." msgstr "" -#: ../../library/multiprocessing.rst:2940 +#: ../../library/multiprocessing.rst:2941 msgid "Below is an example session with logging turned on::" msgstr "" -#: ../../library/multiprocessing.rst:2942 +#: ../../library/multiprocessing.rst:2943 msgid "" ">>> import multiprocessing, logging\n" ">>> logger = multiprocessing.log_to_stderr()\n" @@ -4248,21 +4249,21 @@ msgstr "" "[INFO/MainProcess] sending shutdown message to manager\n" "[INFO/SyncManager-...] manager exiting with exitcode 0" -#: ../../library/multiprocessing.rst:2955 +#: ../../library/multiprocessing.rst:2956 msgid "For a full table of logging levels, see the :mod:`logging` module." msgstr "" -#: ../../library/multiprocessing.rst:2959 +#: ../../library/multiprocessing.rst:2960 msgid "The :mod:`!multiprocessing.dummy` module" msgstr ":mod:`!multiprocessing.dummy` 模組" -#: ../../library/multiprocessing.rst:2964 +#: ../../library/multiprocessing.rst:2965 msgid "" ":mod:`!multiprocessing.dummy` replicates the API of :mod:`!multiprocessing` " "but is no more than a wrapper around the :mod:`threading` module." msgstr "" -#: ../../library/multiprocessing.rst:2969 +#: ../../library/multiprocessing.rst:2970 msgid "" "In particular, the ``Pool`` function provided by :mod:`!multiprocessing." "dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :" @@ -4270,7 +4271,7 @@ msgid "" "worker threads rather than worker processes." msgstr "" -#: ../../library/multiprocessing.rst:2977 +#: ../../library/multiprocessing.rst:2978 msgid "" "A thread pool object which controls a pool of worker threads to which jobs " "can be submitted. :class:`ThreadPool` instances are fully interface " @@ -4280,18 +4281,18 @@ msgid "" "pool.Pool.terminate` manually." msgstr "" -#: ../../library/multiprocessing.rst:2984 +#: ../../library/multiprocessing.rst:2985 msgid "" "*processes* is the number of worker threads to use. If *processes* is " "``None`` then the number returned by :func:`os.process_cpu_count` is used." msgstr "" -#: ../../library/multiprocessing.rst:2990 +#: ../../library/multiprocessing.rst:2991 msgid "" "Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided." msgstr "" -#: ../../library/multiprocessing.rst:2994 +#: ../../library/multiprocessing.rst:2995 msgid "" "A :class:`ThreadPool` shares the same interface as :class:`Pool`, which is " "designed around a pool of processes and predates the introduction of the :" @@ -4301,7 +4302,7 @@ msgid "" "is not understood by any other libraries." msgstr "" -#: ../../library/multiprocessing.rst:3001 +#: ../../library/multiprocessing.rst:3002 msgid "" "Users should generally prefer to use :class:`concurrent.futures." "ThreadPoolExecutor`, which has a simpler interface that was designed around " @@ -4310,69 +4311,69 @@ msgid "" "`asyncio`." msgstr "" -#: ../../library/multiprocessing.rst:3011 +#: ../../library/multiprocessing.rst:3012 msgid "Programming guidelines" msgstr "" -#: ../../library/multiprocessing.rst:3013 +#: ../../library/multiprocessing.rst:3014 msgid "" "There are certain guidelines and idioms which should be adhered to when " "using :mod:`!multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:3018 +#: ../../library/multiprocessing.rst:3019 msgid "All start methods" msgstr "" -#: ../../library/multiprocessing.rst:3020 +#: ../../library/multiprocessing.rst:3021 msgid "The following applies to all start methods." msgstr "" -#: ../../library/multiprocessing.rst:3022 +#: ../../library/multiprocessing.rst:3023 msgid "Avoid shared state" msgstr "" -#: ../../library/multiprocessing.rst:3024 +#: ../../library/multiprocessing.rst:3025 msgid "" "As far as possible one should try to avoid shifting large amounts of data " "between processes." msgstr "" -#: ../../library/multiprocessing.rst:3027 +#: ../../library/multiprocessing.rst:3028 msgid "" "It is probably best to stick to using queues or pipes for communication " "between processes rather than using the lower level synchronization " "primitives." msgstr "" -#: ../../library/multiprocessing.rst:3031 +#: ../../library/multiprocessing.rst:3032 msgid "Picklability" msgstr "" -#: ../../library/multiprocessing.rst:3033 +#: ../../library/multiprocessing.rst:3034 msgid "Ensure that the arguments to the methods of proxies are picklable." msgstr "" -#: ../../library/multiprocessing.rst:3035 +#: ../../library/multiprocessing.rst:3036 msgid "Thread safety of proxies" msgstr "" -#: ../../library/multiprocessing.rst:3037 +#: ../../library/multiprocessing.rst:3038 msgid "" "Do not use a proxy object from more than one thread unless you protect it " "with a lock." msgstr "" -#: ../../library/multiprocessing.rst:3040 +#: ../../library/multiprocessing.rst:3041 msgid "" "(There is never a problem with different processes using the *same* proxy.)" msgstr "" -#: ../../library/multiprocessing.rst:3042 +#: ../../library/multiprocessing.rst:3043 msgid "Joining zombie processes" msgstr "" -#: ../../library/multiprocessing.rst:3044 +#: ../../library/multiprocessing.rst:3045 msgid "" "On POSIX when a process finishes but has not been joined it becomes a " "zombie. There should never be very many because each time a new process " @@ -4383,11 +4384,11 @@ msgid "" "explicitly join all the processes that you start." msgstr "" -#: ../../library/multiprocessing.rst:3052 +#: ../../library/multiprocessing.rst:3053 msgid "Better to inherit than pickle/unpickle" msgstr "" -#: ../../library/multiprocessing.rst:3054 +#: ../../library/multiprocessing.rst:3055 msgid "" "When using the *spawn* or *forkserver* start methods many types from :mod:`!" "multiprocessing` need to be picklable so that child processes can use them. " @@ -4397,11 +4398,11 @@ msgid "" "inherit it from an ancestor process." msgstr "" -#: ../../library/multiprocessing.rst:3062 +#: ../../library/multiprocessing.rst:3063 msgid "Avoid terminating processes" msgstr "" -#: ../../library/multiprocessing.rst:3064 +#: ../../library/multiprocessing.rst:3065 msgid "" "Using the :meth:`Process.terminate ` " "method to stop a process is liable to cause any shared resources (such as " @@ -4409,18 +4410,18 @@ msgid "" "become broken or unavailable to other processes." msgstr "" -#: ../../library/multiprocessing.rst:3070 +#: ../../library/multiprocessing.rst:3071 msgid "" "Therefore it is probably best to only consider using :meth:`Process." "terminate ` on processes which never use " "any shared resources." msgstr "" -#: ../../library/multiprocessing.rst:3074 +#: ../../library/multiprocessing.rst:3075 msgid "Joining processes that use queues" msgstr "" -#: ../../library/multiprocessing.rst:3076 +#: ../../library/multiprocessing.rst:3077 msgid "" "Bear in mind that a process that has put items in a queue will wait before " "terminating until all the buffered items are fed by the \"feeder\" thread to " @@ -4429,7 +4430,7 @@ msgid "" "queue to avoid this behaviour.)" msgstr "" -#: ../../library/multiprocessing.rst:3082 +#: ../../library/multiprocessing.rst:3083 msgid "" "This means that whenever you use a queue you need to make sure that all " "items which have been put on the queue will eventually be removed before the " @@ -4438,11 +4439,11 @@ msgid "" "processes will be joined automatically." msgstr "" -#: ../../library/multiprocessing.rst:3088 +#: ../../library/multiprocessing.rst:3089 msgid "An example which will deadlock is the following::" msgstr "" -#: ../../library/multiprocessing.rst:3090 +#: ../../library/multiprocessing.rst:3091 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -4457,17 +4458,17 @@ msgid "" " obj = queue.get()" msgstr "" -#: ../../library/multiprocessing.rst:3102 +#: ../../library/multiprocessing.rst:3103 msgid "" "A fix here would be to swap the last two lines (or simply remove the ``p." "join()`` line)." msgstr "" -#: ../../library/multiprocessing.rst:3105 +#: ../../library/multiprocessing.rst:3106 msgid "Explicitly pass resources to child processes" msgstr "" -#: ../../library/multiprocessing.rst:3107 +#: ../../library/multiprocessing.rst:3108 msgid "" "On POSIX using the *fork* start method, a child process can make use of a " "shared resource created in a parent process using a global resource. " @@ -4475,7 +4476,7 @@ msgid "" "for the child process." msgstr "" -#: ../../library/multiprocessing.rst:3112 +#: ../../library/multiprocessing.rst:3113 msgid "" "Apart from making the code (potentially) compatible with Windows and the " "other start methods this also ensures that as long as the child process is " @@ -4484,11 +4485,11 @@ msgid "" "collected in the parent process." msgstr "" -#: ../../library/multiprocessing.rst:3119 +#: ../../library/multiprocessing.rst:3120 msgid "So for instance ::" msgstr "" -#: ../../library/multiprocessing.rst:3121 +#: ../../library/multiprocessing.rst:3122 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4510,11 +4511,11 @@ msgstr "" " for i in range(10):\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:3131 +#: ../../library/multiprocessing.rst:3132 msgid "should be rewritten as ::" msgstr "" -#: ../../library/multiprocessing.rst:3133 +#: ../../library/multiprocessing.rst:3134 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4536,25 +4537,25 @@ msgstr "" " for i in range(10):\n" " Process(target=f, args=(lock,)).start()" -#: ../../library/multiprocessing.rst:3143 +#: ../../library/multiprocessing.rst:3144 msgid "Beware of replacing :data:`sys.stdin` with a \"file like object\"" msgstr "" -#: ../../library/multiprocessing.rst:3145 +#: ../../library/multiprocessing.rst:3146 msgid ":mod:`!multiprocessing` originally unconditionally called::" msgstr "" -#: ../../library/multiprocessing.rst:3147 +#: ../../library/multiprocessing.rst:3148 msgid "os.close(sys.stdin.fileno())" msgstr "os.close(sys.stdin.fileno())" -#: ../../library/multiprocessing.rst:3149 +#: ../../library/multiprocessing.rst:3150 msgid "" "in the :meth:`multiprocessing.Process._bootstrap` method --- this resulted " "in issues with processes-in-processes. This has been changed to::" msgstr "" -#: ../../library/multiprocessing.rst:3152 +#: ../../library/multiprocessing.rst:3153 msgid "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" @@ -4562,7 +4563,7 @@ msgstr "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" -#: ../../library/multiprocessing.rst:3155 +#: ../../library/multiprocessing.rst:3156 msgid "" "Which solves the fundamental issue of processes colliding with each other " "resulting in a bad file descriptor error, but introduces a potential danger " @@ -4572,14 +4573,14 @@ msgid "" "data being flushed to the object multiple times, resulting in corruption." msgstr "" -#: ../../library/multiprocessing.rst:3162 +#: ../../library/multiprocessing.rst:3163 msgid "" "If you write a file-like object and implement your own caching, you can make " "it fork-safe by storing the pid whenever you append to the cache, and " "discarding the cache when the pid changes. For example::" msgstr "" -#: ../../library/multiprocessing.rst:3166 +#: ../../library/multiprocessing.rst:3167 msgid "" "@property\n" "def cache(self):\n" @@ -4597,26 +4598,26 @@ msgstr "" " self._cache = []\n" " return self._cache" -#: ../../library/multiprocessing.rst:3174 +#: ../../library/multiprocessing.rst:3175 msgid "" "For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`" msgstr "" -#: ../../library/multiprocessing.rst:3180 +#: ../../library/multiprocessing.rst:3181 msgid "The *spawn* and *forkserver* start methods" msgstr "" -#: ../../library/multiprocessing.rst:3182 +#: ../../library/multiprocessing.rst:3183 msgid "" "There are a few extra restrictions which don't apply to the *fork* start " "method." msgstr "" -#: ../../library/multiprocessing.rst:3185 +#: ../../library/multiprocessing.rst:3186 msgid "More picklability" msgstr "" -#: ../../library/multiprocessing.rst:3187 +#: ../../library/multiprocessing.rst:3188 msgid "" "Ensure that all arguments to :class:`~multiprocessing.Process` are " "picklable. Also, if you subclass ``Process.__init__``, you must make sure " @@ -4624,11 +4625,11 @@ msgid "" "` method is called." msgstr "" -#: ../../library/multiprocessing.rst:3192 +#: ../../library/multiprocessing.rst:3193 msgid "Global variables" msgstr "" -#: ../../library/multiprocessing.rst:3194 +#: ../../library/multiprocessing.rst:3195 msgid "" "Bear in mind that if code run in a child process tries to access a global " "variable, then the value it sees (if any) may not be the same as the value " @@ -4636,30 +4637,30 @@ msgid "" "Process.start>` was called." msgstr "" -#: ../../library/multiprocessing.rst:3199 +#: ../../library/multiprocessing.rst:3200 msgid "" "However, global variables which are just module level constants cause no " "problems." msgstr "" -#: ../../library/multiprocessing.rst:3204 +#: ../../library/multiprocessing.rst:3205 msgid "Safe importing of main module" msgstr "" -#: ../../library/multiprocessing.rst:3206 +#: ../../library/multiprocessing.rst:3207 msgid "" "Make sure that the main module can be safely imported by a new Python " "interpreter without causing unintended side effects (such as starting a new " "process)." msgstr "" -#: ../../library/multiprocessing.rst:3210 +#: ../../library/multiprocessing.rst:3211 msgid "" "For example, using the *spawn* or *forkserver* start method running the " "following module would fail with a :exc:`RuntimeError`::" msgstr "" -#: ../../library/multiprocessing.rst:3214 +#: ../../library/multiprocessing.rst:3215 msgid "" "from multiprocessing import Process\n" "\n" @@ -4677,13 +4678,13 @@ msgstr "" "p = Process(target=foo)\n" "p.start()" -#: ../../library/multiprocessing.rst:3222 +#: ../../library/multiprocessing.rst:3223 msgid "" "Instead one should protect the \"entry point\" of the program by using ``if " "__name__ == '__main__':`` as follows::" msgstr "" -#: ../../library/multiprocessing.rst:3225 +#: ../../library/multiprocessing.rst:3226 msgid "" "from multiprocessing import Process, freeze_support, set_start_method\n" "\n" @@ -4707,33 +4708,33 @@ msgstr "" " p = Process(target=foo)\n" " p.start()" -#: ../../library/multiprocessing.rst:3236 +#: ../../library/multiprocessing.rst:3237 msgid "" "(The ``freeze_support()`` line can be omitted if the program will be run " "normally instead of frozen.)" msgstr "" -#: ../../library/multiprocessing.rst:3239 +#: ../../library/multiprocessing.rst:3240 msgid "" "This allows the newly spawned Python interpreter to safely import the module " "and then run the module's ``foo()`` function." msgstr "" -#: ../../library/multiprocessing.rst:3242 +#: ../../library/multiprocessing.rst:3243 msgid "" "Similar restrictions apply if a pool or manager is created in the main " "module." msgstr "" -#: ../../library/multiprocessing.rst:3249 +#: ../../library/multiprocessing.rst:3250 msgid "Examples" msgstr "範例" -#: ../../library/multiprocessing.rst:3251 +#: ../../library/multiprocessing.rst:3252 msgid "Demonstration of how to create and use customized managers and proxies:" msgstr "" -#: ../../library/multiprocessing.rst:3253 +#: ../../library/multiprocessing.rst:3254 msgid "" "from multiprocessing import freeze_support\n" "from multiprocessing.managers import BaseManager, BaseProxy\n" @@ -4827,11 +4828,11 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3257 +#: ../../library/multiprocessing.rst:3258 msgid "Using :class:`~multiprocessing.pool.Pool`:" msgstr "使用 :class:`~multiprocessing.pool.Pool`:" -#: ../../library/multiprocessing.rst:3259 +#: ../../library/multiprocessing.rst:3260 msgid "" "import multiprocessing\n" "import time\n" @@ -4991,13 +4992,13 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3263 +#: ../../library/multiprocessing.rst:3264 msgid "" "An example showing how to use queues to feed tasks to a collection of worker " "processes and collect the results:" msgstr "" -#: ../../library/multiprocessing.rst:3266 +#: ../../library/multiprocessing.rst:3267 msgid "" "import time\n" "import random\n"