diff --git a/library/_thread.po b/library/_thread.po index dec384a0ef..cc148fae2f 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -31,26 +31,30 @@ msgid "" "provided. The :mod:`threading` module provides an easier to use and higher-" "level threading API built on top of this module." msgstr "" +"這個模組提供了與多個執行緒(也稱為:dfn:`輕量級行程` 或 :dfn: `任務`)一起工作" +"的低階原始物件 --- 多個控制執行緒分享其全域資料空間。為了處理同步問題,也提供了簡" +"單的鎖 (lock) 機制(也稱為:dfn:`互斥鎖` 或 :dfn:`二進位號誌`)。 :mod:" +"`threading` 模組提供了一個建立在這個模組之上的更易於使用和高階的執行緒 API。" #: ../../library/_thread.rst:26 msgid "This module used to be optional, it is now always available." -msgstr "" +msgstr "這個模組之前是可選擇性的,但現在已經是可用的。" #: ../../library/_thread.rst:29 msgid "This module defines the following constants and functions:" -msgstr "" +msgstr "這個模組定義了以下的常數和函式:" #: ../../library/_thread.rst:33 msgid "Raised on thread-specific errors." -msgstr "" +msgstr "在執行緒相關的錯誤發生時引發。" #: ../../library/_thread.rst:35 msgid "This is now a synonym of the built-in :exc:`RuntimeError`." -msgstr "" +msgstr "現在是內建例外 :exc:`RuntimeError` 的別名。" #: ../../library/_thread.rst:41 msgid "This is the type of lock objects." -msgstr "" +msgstr "這是鎖物件的型別。" #: ../../library/_thread.rst:46 msgid "" @@ -58,10 +62,13 @@ msgid "" "function *function* with the argument list *args* (which must be a tuple). " "The optional *kwargs* argument specifies a dictionary of keyword arguments." msgstr "" +"開始一個新的執行緒並回傳其識別字 (identifier) 。該執行緒執行帶有引數列表 " +"*args*(必須是一個 tuple(元組))的函式 *function*。可選的 *kwargs* 引數指定" +"一個關鍵字引數的字典。" #: ../../library/_thread.rst:50 msgid "When the function returns, the thread silently exits." -msgstr "" +msgstr "當函式回傳時,執行緒會靜默退出。" #: ../../library/_thread.rst:52 msgid "" @@ -70,22 +77,27 @@ msgid "" "the hook argument is *function*. By default, a stack trace is printed and " "then the thread exits (but other threads continue to run)." msgstr "" +"當函式因未處理的例外終止時,將呼叫 :func:`sys.unraisablehook` 來處理該例外。鉤" +"子引數的 *object* 屬性是 *function*。預設情況下,會列印堆疊跟蹤,然後執行緒退" +"出(但其他執行緒會繼續運行)。" #: ../../library/_thread.rst:57 msgid "" "When the function raises a :exc:`SystemExit` exception, it is silently " "ignored." -msgstr "" +msgstr "當函式引發 :exc:`SystemExit` 例外時,它會被靜默忽略。" #: ../../library/_thread.rst:60 msgid "" "Raises an :ref:`auditing event ` ``_thread.start_new_thread`` with " "arguments ``function``, ``args``, ``kwargs``." msgstr "" +"引發一個 :ref:`稽核事件 ` ``_thread.start_new_thread``,帶有引數 " +"``function``、``args`` 和 ``kwargs``。" #: ../../library/_thread.rst:62 msgid ":func:`sys.unraisablehook` is now used to handle unhandled exceptions." -msgstr "" +msgstr "現在使用 :func:`sys.unraisablehook` 來處理未處理的例外。" #: ../../library/_thread.rst:68 msgid "" @@ -93,22 +105,28 @@ msgid "" "use this function to interrupt the main thread, though there is no guarantee " "that the interruption will happen immediately." msgstr "" +"模擬一個訊號到達主執行緒的效果。執行緒可以使用此函式來中斷主執行緒,但無法保" +"證中斷會立即發生。" #: ../../library/_thread.rst:72 msgid "" "If given, *signum* is the number of the signal to simulate. If *signum* is " "not given, :const:`signal.SIGINT` is simulated." msgstr "" +"如果提供了 *signum*,則模擬指定的訊號編號。如果未提供 *signum*,則模擬 :" +"const:`signal.SIGINT` 訊號。" #: ../../library/_thread.rst:75 msgid "" "If the given signal isn't handled by Python (it was set to :const:`signal." "SIG_DFL` or :const:`signal.SIG_IGN`), this function does nothing." msgstr "" +"如果給定的訊號在 Python 中未被處理(即設置為 :const:`signal.SIG_DFL` 或 :" +"const:`signal.SIG_IGN`),此函式不做任何操作。" #: ../../library/_thread.rst:79 msgid "The *signum* argument is added to customize the signal number." -msgstr "" +msgstr "新增了 *signum* 引數以自定義訊號編號。" #: ../../library/_thread.rst:83 msgid "" @@ -116,18 +134,20 @@ msgid "" "associated handler (if it exists). If you want to truly emit the signal, " "use :func:`signal.raise_signal`." msgstr "" +"這並不會發出對應的訊號,而是安排呼叫相應的處理器(如果存在的話)。如果您想真" +"正發出訊號,請使用 :func:`signal.raise_signal`。" #: ../../library/_thread.rst:90 msgid "" "Raise the :exc:`SystemExit` exception. When not caught, this will cause the " "thread to exit silently." -msgstr "" +msgstr "引發 :exc:`SystemExit` 例外。當未捕獲時,將導致執行緒靜默退出。" #: ../../library/_thread.rst:104 msgid "" "Return a new lock object. Methods of locks are described below. The lock " "is initially unlocked." -msgstr "" +msgstr "回傳一個新的鎖物件。鎖物件的方法如下所述。初始狀況下鎖是解鎖狀態。" #: ../../library/_thread.rst:110 msgid "" @@ -137,6 +157,9 @@ msgid "" "identifiers may be recycled when a thread exits and another thread is " "created." msgstr "" +"回傳當前執行緒的「執行緒識別字」。這是一個非零的整數。它的值沒有直接的含義;" +"它被用作一個 magic cookie,例如用於索引特定於執行緒的資料的字典。當執行緒退出" +"並建立另一個執行緒時,執行緒識別字可能會被重複使用。" #: ../../library/_thread.rst:118 msgid "" @@ -145,6 +168,9 @@ msgid "" "identify this particular thread system-wide (until the thread terminates, " "after which the value may be recycled by the OS)." msgstr "" +"回傳由核心 (kernel) 分配的當前執行緒的原生整數執行緒 ID。這是一個非負整數。它" +"的值可用於在整個系統中唯一標識此特定執行緒(直到執行緒終止後,該值可能被操作" +"系統重新使用)。" #: ../../library/_thread.rst:123 msgid "" @@ -172,6 +198,15 @@ msgid "" "stack size is the suggested approach in the absence of more specific " "information)." msgstr "" +"回傳在建立新執行緒時使用的執行緒堆疊大小。可選的 *size* 引數指定了隨後建立的" +"執行緒要使用的堆疊大小,必須是 0(使用平台或配置的預設值)或至少 32,768(32 " +"KiB)的正整數值。如果未指定 *size*,則使用 0。如果不支持更改執行緒堆疊大小," +"則會引發 :exc:`RuntimeError` 錯誤。如果指定的堆疊大小無效,則會引發 :exc:" +"`ValueError` 錯誤,並且堆疊大小不會被修改。目前,32 KiB 是保證解譯器本身具有" +"足夠堆疊空間所支持的最小堆疊大小值。請注意,某些平台對於堆疊大小的值可能有特" +"定的限制,例如要求最小堆疊大小 > 32 KiB,或要求按系統記憶體頁面大小的倍數進行" +"分配。應參考平台文檔以獲取更多訊息(4 KiB 頁面是比較普遍的;在缺乏更具體訊息" +"的情況下,建議使用 4096 的倍數作為堆疊大小)。" #: ../../library/_thread.rst:145 msgid ":ref:`Availability `: Windows, pthreads." @@ -179,7 +214,7 @@ msgstr ":ref:`適用 `:Windows, pthreads。" #: ../../library/_thread.rst:147 msgid "Unix platforms with POSIX threads support." -msgstr "" +msgstr "Unix 平台上支援 POSIX 執行緒。" #: ../../library/_thread.rst:152 msgid "" @@ -187,10 +222,12 @@ msgid "" "`. Specifying a timeout greater than this value will " "raise an :exc:`OverflowError`." msgstr "" +":meth:`Lock.acquire ` 的 *timeout* 參數所允許的最大" +"值。指定超過此值的 timeout 將引發 :exc:`OverflowError` 錯誤。" #: ../../library/_thread.rst:159 msgid "Lock objects have the following methods:" -msgstr "" +msgstr "鎖物件具有以下方法:" #: ../../library/_thread.rst:164 msgid "" @@ -199,6 +236,8 @@ msgid "" "(only one thread at a time can acquire a lock --- that's their reason for " "existence)." msgstr "" +"沒有任何可選引數時,此方法無條件地獲取鎖,必要時會等待直到被另一個執行緒釋放" +"(一次只能有一個執行緒獲取鎖 --- 這正是鎖存在的原因)。" #: ../../library/_thread.rst:168 msgid "" @@ -207,6 +246,8 @@ msgid "" "without waiting, while if it is true, the lock is acquired unconditionally " "as above." msgstr "" +"如果存在 *blocking* 引數,則根據其值執行操作:如果為 False,只有在可以立即獲" +"取鎖而無需等待的情況下才獲取鎖,而如果為 True,則像上面一樣無條件地獲取鎖。" #: ../../library/_thread.rst:173 msgid "" @@ -215,42 +256,46 @@ msgid "" "*timeout* argument specifies an unbounded wait. You cannot specify a " "*timeout* if *blocking* is false." msgstr "" +"如果存在浮點數的 *timeout* 引數且為正值,則它指定了在回傳之前的最大等待時間" +"(以秒為單位)。如果 *timeout* 引數為負值,則表示等待時間會無限期地等待。如" +"果 *blocking* 為 False,則你無法指定 *timeout*。" #: ../../library/_thread.rst:178 msgid "" "The return value is ``True`` if the lock is acquired successfully, ``False`` " "if not." -msgstr "" +msgstr "如果成功獲取鎖,回傳值為 ``True``,否則為 ``False``。" #: ../../library/_thread.rst:181 msgid "The *timeout* parameter is new." -msgstr "" +msgstr "新增的 *timeout* 參數。" #: ../../library/_thread.rst:184 msgid "Lock acquires can now be interrupted by signals on POSIX." -msgstr "" +msgstr "現在獲取鎖的操作可以被 POSIX 訊號中斷。" #: ../../library/_thread.rst:190 msgid "" "Releases the lock. The lock must have been acquired earlier, but not " "necessarily by the same thread." -msgstr "" +msgstr "釋放鎖。鎖必須先前被獲取,但不一定是由同一個執行緒獲取的。" #: ../../library/_thread.rst:196 msgid "" "Return the status of the lock: ``True`` if it has been acquired by some " "thread, ``False`` if not." msgstr "" +"回傳鎖的狀態:如果鎖已被某個執行緒獲取,則回傳 ``True``,否則回傳 ``False``。" #: ../../library/_thread.rst:199 msgid "" "In addition to these methods, lock objects can also be used via the :keyword:" "`with` statement, e.g.::" -msgstr "" +msgstr "除了這些方法之外,鎖物件還可以透過 :keyword:`with` 語句來使用,例如:" #: ../../library/_thread.rst:209 msgid "**Caveats:**" -msgstr "" +msgstr "**注意事項:**" #: ../../library/_thread.rst:213 msgid "" @@ -258,12 +303,17 @@ msgid "" "exception will be received by an arbitrary thread. (When the :mod:`signal` " "module is available, interrupts always go to the main thread.)" msgstr "" +"執行緒與中斷的互動可能會有奇怪的情況:任何一個執行緒都有可能收到 :exc:" +"`KeyboardInterrupt` 例外。(當 :mod:`signal` 模組可用時,中斷總是會進入主執行" +"緒。)" #: ../../library/_thread.rst:217 msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." msgstr "" +"呼叫 :func:`sys.exit` 函數或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" +"`_thread.exit` 函式。" #: ../../library/_thread.rst:220 msgid "" @@ -271,6 +321,8 @@ msgid "" "on a lock --- the :exc:`KeyboardInterrupt` exception will happen after the " "lock has been acquired." msgstr "" +"無法在鎖的 :meth:`~threading.Lock.acquire` 方法上中斷執行, :exc:" +"`KeyboardInterrupt` 例外會在鎖被獲取後發生。" #: ../../library/_thread.rst:224 msgid "" @@ -278,6 +330,9 @@ msgid "" "survive. On most systems, they are killed without executing :keyword:" "`try` ... :keyword:`finally` clauses or executing object destructors." msgstr "" +"當主執行緒退出時,其他執行緒是否保留是由系統決定的。在大多數系統上,它們將被" +"終止,而不會執行 :keyword:`try` ... :keyword:`finally` 子句或執行物件的解構函" +"式。" #: ../../library/_thread.rst:229 msgid "" @@ -285,30 +340,32 @@ msgid "" "that :keyword:`try` ... :keyword:`finally` clauses are honored), and the " "standard I/O files are not flushed." msgstr "" +"當主執行緒退出時,它不會執行任何通常的清理操作(除非有 :keyword:`try` ... :" +"keyword:`finally` 子句),並且標準 I/O 檔案不會被刷新。" #: ../../library/_thread.rst:7 msgid "light-weight processes" -msgstr "" +msgstr "light-weight processes(輕量級行程)" #: ../../library/_thread.rst:7 msgid "processes, light-weight" -msgstr "" +msgstr "processes, light-weight(行程,輕量級)" #: ../../library/_thread.rst:7 msgid "binary semaphores" -msgstr "" +msgstr "binary semaphores(二進位號誌)" #: ../../library/_thread.rst:7 msgid "semaphores, binary" -msgstr "" +msgstr "semaphores, binary(號誌,二進位)" #: ../../library/_thread.rst:22 msgid "pthreads" -msgstr "" +msgstr "pthreads" #: ../../library/_thread.rst:22 msgid "threads" -msgstr "" +msgstr "threads(執行緒)" #: ../../library/_thread.rst:22 msgid "POSIX"