diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 2590371a0e..f606956dc7 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -17,23 +17,23 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 3.0.1\n" +"X-Generator: Poedit 3.4.2\n" #: ../../library/asyncio-eventloop.rst:8 msgid "Event Loop" -msgstr "" +msgstr "事件迴圈" #: ../../library/asyncio-eventloop.rst:10 msgid "" "**Source code:** :source:`Lib/asyncio/events.py`, :source:`Lib/asyncio/" "base_events.py`" msgstr "" -"**原始碼:**\\ :source:`Lib/asyncio/events.py`\\ 、\\ :source:`Lib/asyncio/" +"**原始碼:** :source:`Lib/asyncio/events.py`、:source:`Lib/asyncio/" "base_events.py`" #: ../../library/asyncio-eventloop.rst:16 msgid "Preface" -msgstr "" +msgstr "前言" #: ../../library/asyncio-eventloop.rst:17 msgid "" @@ -41,6 +41,8 @@ msgid "" "asynchronous tasks and callbacks, perform network IO operations, and run " "subprocesses." msgstr "" +"事件迴圈是每個 asyncio 應用程式的核心。事件迴圈執行非同步任務和回呼、執行網" +"路 IO 操作並啟動子行程。" #: ../../library/asyncio-eventloop.rst:21 msgid "" @@ -50,44 +52,51 @@ msgid "" "authors of lower-level code, libraries, and frameworks, who need finer " "control over the event loop behavior." msgstr "" +"應用程式開發人員通常應使用高階的 asyncio 函式,例如 :func:`asyncio.run`,並且" +"很少需要參照事件迴圈物件或呼叫其方法。本節主要針對那些需要更細粒度控制事件迴" +"圈行為的低階程式碼、函式庫和框架的作者。" #: ../../library/asyncio-eventloop.rst:28 msgid "Obtaining the Event Loop" -msgstr "" +msgstr "取得事件迴圈" #: ../../library/asyncio-eventloop.rst:29 msgid "" "The following low-level functions can be used to get, set, or create an " "event loop:" -msgstr "" +msgstr "以下的低階函式可用於取得、設置或建立事件迴圈:" #: ../../library/asyncio-eventloop.rst:34 msgid "Return the running event loop in the current OS thread." -msgstr "" +msgstr "在當前作業系統執行緒中回傳正在運行的事件迴圈。" #: ../../library/asyncio-eventloop.rst:36 msgid "Raise a :exc:`RuntimeError` if there is no running event loop." -msgstr "" +msgstr "如果沒有運行的事件迴圈,則引發 :exc:`RuntimeError`。" #: ../../library/asyncio-eventloop.rst:38 msgid "This function can only be called from a coroutine or a callback." -msgstr "" +msgstr "此函式只能從協程或回呼函式中呼叫。" #: ../../library/asyncio-eventloop.rst:44 msgid "Get the current event loop." -msgstr "" +msgstr "取得目前的事件迴圈。" #: ../../library/asyncio-eventloop.rst:46 msgid "" "When called from a coroutine or a callback (e.g. scheduled with call_soon or " "similar API), this function will always return the running event loop." msgstr "" +"當從協程或回呼函式呼叫此函式(例如,使用 call_soon 或類似的 API 於排程呼" +"叫),此函式將永遠回傳正在運行的事件迴圈。" #: ../../library/asyncio-eventloop.rst:50 msgid "" "If there is no running event loop set, the function will return the result " "of the ``get_event_loop_policy().get_event_loop()`` call." msgstr "" +"如果沒有設定正在運行的事件迴圈,該函式將回傳 ``get_event_loop_policy()." +"get_event_loop()`` 呼叫的結果。" #: ../../library/asyncio-eventloop.rst:53 msgid "" @@ -95,6 +104,9 @@ msgid "" "event loop policies are in use), using the :func:`get_running_loop` function " "is preferred to :func:`get_event_loop` in coroutines and callbacks." msgstr "" +"由於此函式具有相當複雜的行為(尤其是在使用自訂事件迴圈策略時),在協程和回呼" +"函式中,建議使用 :func:`get_running_loop` 函式,而不是 :func:" +"`get_event_loop`。" #: ../../library/asyncio-eventloop.rst:58 msgid "" @@ -102,20 +114,24 @@ msgid "" "function, instead of using these lower level functions to manually create " "and close an event loop." msgstr "" +"如上所述,可以考慮使用高階的 :func:`asyncio.run` 函式,而不是使用這些較低階的" +"函式手動建立和關閉事件迴圈。" #: ../../library/asyncio-eventloop.rst:62 msgid "" "Deprecation warning is emitted if there is no current event loop. In some " "future Python release this will become an error." msgstr "" +"如果沒有當前事件迴圈,則會發出棄用警告。在未來的某個 Python 發行版中,這將變" +"成錯誤。" #: ../../library/asyncio-eventloop.rst:68 msgid "Set *loop* as the current event loop for the current OS thread." -msgstr "" +msgstr "將 *loop* 設置為當前 OS 執行緒的當前事件迴圈。" #: ../../library/asyncio-eventloop.rst:72 msgid "Create and return a new event loop object." -msgstr "" +msgstr "建立並回傳新的事件迴圈物件。" #: ../../library/asyncio-eventloop.rst:74 msgid "" @@ -123,6 +139,9 @@ msgid "" "and :func:`new_event_loop` functions can be altered by :ref:`setting a " "custom event loop policy `." msgstr "" +"請注意 :func:`get_event_loop`、:func:`set_event_loop` 和 :func:" +"`new_event_loop` 函式的行為可以透過\\ :ref:`設定自訂事件迴圈策略 `\\ 進行調整。" #: ../../library/asyncio-eventloop.rst:80 msgid "Contents" @@ -130,13 +149,14 @@ msgstr "目錄" #: ../../library/asyncio-eventloop.rst:81 msgid "This documentation page contains the following sections:" -msgstr "" +msgstr "本頁文件包含以下章節:" #: ../../library/asyncio-eventloop.rst:83 msgid "" "The `Event Loop Methods`_ section is the reference documentation of the " "event loop APIs;" msgstr "" +"`事件迴圈方法 `_\\ 章節是事件迴圈 API 們的參照文件;" #: ../../library/asyncio-eventloop.rst:86 msgid "" @@ -144,53 +164,62 @@ msgid "" "`TimerHandle` instances which are returned from scheduling methods such as :" "meth:`loop.call_soon` and :meth:`loop.call_later`;" msgstr "" +"`回呼處理 `_\\ 章節記錄了從排程方法(如 :meth:`loop." +"call_soon` 和 :meth:`loop.call_later`)回傳的 :class:`Handle` 和 :class:" +"`TimerHandle` 實例;" #: ../../library/asyncio-eventloop.rst:90 msgid "" "The `Server Objects`_ section documents types returned from event loop " "methods like :meth:`loop.create_server`;" msgstr "" +"`Server 物件 `_\\ 章節記錄了從事件迴圈方法(如 :meth:`loop." +"create_server`)回傳的資料型別;" #: ../../library/asyncio-eventloop.rst:93 msgid "" "The `Event Loop Implementations`_ section documents the :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop` classes;" msgstr "" +"`事件迴圈實作 `_\\ 章節記錄了 :class:" +"`SelectorEventLoop` 和 :class:`ProactorEventLoop` 類別;" #: ../../library/asyncio-eventloop.rst:96 msgid "" "The `Examples`_ section showcases how to work with some event loop APIs." -msgstr "" +msgstr "`範例 `_\\ 章節展示了如何使用一些事件迴圈 API。" #: ../../library/asyncio-eventloop.rst:103 msgid "Event Loop Methods" -msgstr "" +msgstr "事件迴圈方法" #: ../../library/asyncio-eventloop.rst:105 msgid "Event loops have **low-level** APIs for the following:" -msgstr "" +msgstr "事件迴圈提供以下\\ **低階** API:" #: ../../library/asyncio-eventloop.rst:113 msgid "Running and stopping the loop" -msgstr "" +msgstr "啟動和停止迴圈" #: ../../library/asyncio-eventloop.rst:117 msgid "Run until the *future* (an instance of :class:`Future`) has completed." -msgstr "" +msgstr "運行直到 *future* (一個 :class:`Future` 實例)完成。" #: ../../library/asyncio-eventloop.rst:120 msgid "" "If the argument is a :ref:`coroutine object ` it is implicitly " "scheduled to run as a :class:`asyncio.Task`." msgstr "" +"如果引數是\\ :ref:`協程物件 `,則它將被隱式排程為 :class:`asyncio." +"Task` 運行。" #: ../../library/asyncio-eventloop.rst:123 msgid "Return the Future's result or raise its exception." -msgstr "" +msgstr "回傳 Future 的結果或引發其例外。" #: ../../library/asyncio-eventloop.rst:127 msgid "Run the event loop until :meth:`stop` is called." -msgstr "" +msgstr "運行事件迴圈直到 :meth:`stop` 被呼叫。" #: ../../library/asyncio-eventloop.rst:129 msgid "" @@ -199,6 +228,9 @@ msgid "" "scheduled in response to I/O events (and those that were already scheduled), " "and then exit." msgstr "" +"如果在呼叫 :meth:`run_forever()` 之前呼叫 :meth:`stop`,則迴圈將使用超時為零" +"的方式輪詢 I/O 選擇器,運行所有回應 I/O 事件(以及已經排程的事件)的回呼函" +"數,然後退出。" #: ../../library/asyncio-eventloop.rst:134 msgid "" @@ -208,40 +240,43 @@ msgid "" "will run the next time :meth:`run_forever` or :meth:`run_until_complete` is " "called." msgstr "" +"如果在 :meth:`run_forever` 運行時呼叫 :meth:`stop`,則迴圈將運行當前批次的回" +"呼函式,然後退出。請注意,由回呼函式排程的新回呼在此情況下不會運行;而是在下" +"次呼叫 :meth:`run_forever` 或 :meth:`run_until_complete` 時運行。" #: ../../library/asyncio-eventloop.rst:142 msgid "Stop the event loop." -msgstr "" +msgstr "停止事件迴圈。" #: ../../library/asyncio-eventloop.rst:146 msgid "Return ``True`` if the event loop is currently running." -msgstr "" +msgstr "如果事件迴圈當前正在運行,則回傳 ``True``。" #: ../../library/asyncio-eventloop.rst:150 msgid "Return ``True`` if the event loop was closed." -msgstr "" +msgstr "如果事件迴圈已關閉,則回傳 ``True``。" #: ../../library/asyncio-eventloop.rst:154 msgid "Close the event loop." -msgstr "" +msgstr "關閉事件迴圈。" #: ../../library/asyncio-eventloop.rst:156 msgid "" "The loop must not be running when this function is called. Any pending " "callbacks will be discarded." -msgstr "" +msgstr "不得於迴圈運行中呼叫此函式。將丟棄任何待處理的回呼。" #: ../../library/asyncio-eventloop.rst:159 msgid "" "This method clears all queues and shuts down the executor, but does not wait " "for the executor to finish." -msgstr "" +msgstr "此方法清除所有佇列並關閉執行器,但不等待執行器完成。" #: ../../library/asyncio-eventloop.rst:162 msgid "" "This method is idempotent and irreversible. No other methods should be " "called after the event loop is closed." -msgstr "" +msgstr "此方法是冪等且不可逆的。在事件迴圈關閉後不應呼叫其他方法。" #: ../../library/asyncio-eventloop.rst:167 msgid "" @@ -250,21 +285,21 @@ msgid "" "loop will issue a warning if a new asynchronous generator is iterated. This " "should be used to reliably finalize all scheduled asynchronous generators." msgstr "" +"排程所有當前打開的\\ :term:`非同步產生器 `\\ 物件使" +"用 :meth:`~agen.aclose()` 呼叫來關閉。呼叫此方法後,如果疊代新的非同步產生" +"器,事件迴圈將發出警告。應該使用此方法可靠地完成所有已排程的非同步產生器。" #: ../../library/asyncio-eventloop.rst:173 msgid "" "Note that there is no need to call this function when :func:`asyncio.run` is " "used." -msgstr "" +msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" #: ../../library/asyncio-eventloop.rst:176 #: ../../library/asyncio-eventloop.rst:1242 #: ../../library/asyncio-eventloop.rst:1660 msgid "Example::" -msgstr "" -"範例:\n" -"\n" -"::" +msgstr "範例: ::" #: ../../library/asyncio-eventloop.rst:188 msgid "" @@ -273,6 +308,9 @@ msgid "" "this method has been called, using the default executor with :meth:`loop." "run_in_executor` will raise a :exc:`RuntimeError`." msgstr "" +"排程預設執行器的關閉,並等待它加入 :class:`~concurrent.futures." +"ThreadPoolExecutor` 中的所有執行緒。一旦呼叫了此方法,使用預設執行器與 :meth:" +"`loop.run_in_executor` 將引發 :exc:`RuntimeError`。" #: ../../library/asyncio-eventloop.rst:194 msgid "" @@ -280,6 +318,8 @@ msgid "" "seconds) the executor will be given to finish joining. With the default, " "``None``, the executor is allowed an unlimited amount of time." msgstr "" +"*timeout* 參數指定執行器完成加入所需的時間(以 :class:`float` 秒為單位)。預" +"設情況下為 ``None``,不會限制執行器所花費的時間。" #: ../../library/asyncio-eventloop.rst:199 msgid "" @@ -287,12 +327,16 @@ msgid "" "default executor is terminated without waiting for its threads to finish " "joining." msgstr "" +"如果達到 *timeout*,將發出 :exc:`RuntimeWarning` 警告,預設執行器將立即終止," +"不等待其執行緒完成加入。" #: ../../library/asyncio-eventloop.rst:205 msgid "" "Do not call this method when using :func:`asyncio.run`, as the latter " "handles default executor shutdown automatically." msgstr "" +"使用 :func:`asyncio.run` 時請勿呼叫此方法,因為後者會自動處理預設執行器的關" +"閉。" #: ../../library/asyncio-eventloop.rst:210 msgid "Added the *timeout* parameter." @@ -300,25 +344,27 @@ msgstr "加入 *timeout* 參數。" #: ../../library/asyncio-eventloop.rst:214 msgid "Scheduling callbacks" -msgstr "" +msgstr "排程回呼函式" #: ../../library/asyncio-eventloop.rst:218 msgid "" "Schedule the *callback* :term:`callback` to be called with *args* arguments " "at the next iteration of the event loop." msgstr "" +"在事件迴圈的下一次疊代中排程以 *args* 引數呼叫 *callback* :term:" +"`callback`。" #: ../../library/asyncio-eventloop.rst:221 msgid "" "Return an instance of :class:`asyncio.Handle`, which can be used later to " "cancel the callback." -msgstr "" +msgstr "回傳 :class:`asyncio.Handle` 的實例,稍後可以用於取消回呼函式。" #: ../../library/asyncio-eventloop.rst:224 msgid "" "Callbacks are called in the order in which they are registered. Each " "callback will be called exactly once." -msgstr "" +msgstr "回呼函式按照其註冊的順序呼叫。每個回呼函式將被呼叫恰好一次。" #: ../../library/asyncio-eventloop.rst:227 msgid "" @@ -326,10 +372,12 @@ msgid "" "`contextvars.Context` for the *callback* to run in. Callbacks use the " "current context when no *context* is provided." msgstr "" +"選用的僅限關鍵字引數 *context* 指定了要給 *callback* 執行的自定義 :class:" +"`contextvars.Context`。當未提供 *context* 時,回呼函式使用當前情境。" #: ../../library/asyncio-eventloop.rst:231 msgid "Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe." -msgstr "" +msgstr "與 :meth:`call_soon_threadsafe` 不同,此方法不是執行緒安全的。" #: ../../library/asyncio-eventloop.rst:235 msgid "" @@ -337,18 +385,22 @@ msgid "" "another thread, this function *must* be used, since :meth:`call_soon` is not " "thread-safe." msgstr "" +"這是 :meth:`call_soon` 的執行緒安全變體。當從另一個執行緒排程回呼函式時,*必須*\ " +"使用此函式,因為 :meth:`call_soon` 不是執行緒安全的。" #: ../../library/asyncio-eventloop.rst:239 msgid "" "Raises :exc:`RuntimeError` if called on a loop that's been closed. This can " "happen on a secondary thread when the main application is shutting down." msgstr "" +"如果在已關閉的迴圈上呼叫,則引發 :exc:`RuntimeError`。在主應用程式關閉時,這" +"可能發生在次要執行緒上。" #: ../../library/asyncio-eventloop.rst:243 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." -msgstr "" +msgstr "請參閱文件的\\ :ref:`並行和多執行緒 `\\ 部分。" #: ../../library/asyncio-eventloop.rst:246 #: ../../library/asyncio-eventloop.rst:296 @@ -356,48 +408,56 @@ msgstr "" msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." -msgstr "" +msgstr "新增了 *context* 僅限關鍵字參數。詳細資訊請參閱 :pep:`567`。" #: ../../library/asyncio-eventloop.rst:254 msgid "" "Most :mod:`asyncio` scheduling functions don't allow passing keyword " "arguments. To do that, use :func:`functools.partial`::" msgstr "" +"大多數 :mod:`asyncio` 排程函式不允許傳遞關鍵字引數。要傳遞關鍵字引數,請使" +"用 :func:`functools.partial`: ::" #: ../../library/asyncio-eventloop.rst:261 msgid "" "Using partial objects is usually more convenient than using lambdas, as " "asyncio can render partial objects better in debug and error messages." msgstr "" +"通常使用 partial 物件比使用 lambda 更方便,因為 asyncio 可以在除錯和錯誤訊息" +"中更好地呈現 partial 物件。" #: ../../library/asyncio-eventloop.rst:269 msgid "Scheduling delayed callbacks" -msgstr "" +msgstr "排程延遲的回呼函式" #: ../../library/asyncio-eventloop.rst:271 msgid "" "Event loop provides mechanisms to schedule callback functions to be called " "at some point in the future. Event loop uses monotonic clocks to track time." msgstr "" +"事件迴圈提供為回呼函式排程在將來某個時間點才呼叫的機制。事件迴圈使用了單調時" +"鐘來追蹤時間。" #: ../../library/asyncio-eventloop.rst:278 msgid "" "Schedule *callback* to be called after the given *delay* number of seconds " "(can be either an int or a float)." -msgstr "" +msgstr "排程 *callback* 在給定的 *delay* 秒數後呼叫(可以是整數或浮點數)。" #: ../../library/asyncio-eventloop.rst:281 #: ../../library/asyncio-eventloop.rst:313 msgid "" "An instance of :class:`asyncio.TimerHandle` is returned which can be used to " "cancel the callback." -msgstr "" +msgstr "回傳 :class:`asyncio.TimerHandle` 的實例,可用於取消回呼函式。" #: ../../library/asyncio-eventloop.rst:284 msgid "" "*callback* will be called exactly once. If two callbacks are scheduled for " "exactly the same time, the order in which they are called is undefined." msgstr "" +"*callback* 將只被呼叫恰好一次。如果有兩個回呼函式被排程在完全相同的時間,則其呼叫" +"順序是不定的。" #: ../../library/asyncio-eventloop.rst:288 msgid "" @@ -405,6 +465,8 @@ msgid "" "called. If you want the callback to be called with keyword arguments use :" "func:`functools.partial`." msgstr "" +"可選的位置引數 *args* 將在呼叫回呼函式時傳遞。如果要使用關鍵字引數呼叫回呼函" +"數,請使用 :func:`functools.partial`。" #: ../../library/asyncio-eventloop.rst:292 msgid "" @@ -412,22 +474,28 @@ msgid "" "class:`contextvars.Context` for the *callback* to run in. The current " "context is used when no *context* is provided." msgstr "" +"可選的僅限關鍵字 *context* 引數允許為 *callback* 指定自定義的 :class:" +"`contextvars.Context` 以提供運行。當未提供 *context* 時,將使用當前情境。" #: ../../library/asyncio-eventloop.rst:300 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "*delay* could not exceed one day. This has been fixed in Python 3.8." msgstr "" +"在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*delay* 不能超過一天。這在 " +"Python 3.8 中已經修復。" #: ../../library/asyncio-eventloop.rst:307 msgid "" "Schedule *callback* to be called at the given absolute timestamp *when* (an " "int or a float), using the same time reference as :meth:`loop.time`." msgstr "" +"排程 *callback* 在給定的絕對時間戳 *when* (整數或浮點數)處呼叫,使用與 :" +"meth:`loop.time` 相同的時間參照。" #: ../../library/asyncio-eventloop.rst:311 msgid "This method's behavior is the same as :meth:`call_later`." -msgstr "" +msgstr "此方法的行為與 :meth:`call_later` 相同。" #: ../../library/asyncio-eventloop.rst:320 msgid "" @@ -435,30 +503,34 @@ msgid "" "difference between *when* and the current time could not exceed one day. " "This has been fixed in Python 3.8." msgstr "" +"在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*when* 和當前時間之間的差值" +"不能超過一天。這在 Python 3.8 中已經修復。" #: ../../library/asyncio-eventloop.rst:327 msgid "" "Return the current time, as a :class:`float` value, according to the event " "loop's internal monotonic clock." -msgstr "" +msgstr "根據事件迴圈的內部單調時鐘,回傳當前時間,以 :class:`float` 值表示。" #: ../../library/asyncio-eventloop.rst:331 msgid "" "In Python 3.7 and earlier timeouts (relative *delay* or absolute *when*) " "should not exceed one day. This has been fixed in Python 3.8." msgstr "" +"在 Python 3.7 及更早版本中,超時(相對 *delay* 或絕對 *when*)不應超過一天。" +"這在 Python 3.8 中已經修復。" #: ../../library/asyncio-eventloop.rst:337 msgid "The :func:`asyncio.sleep` function." -msgstr "" +msgstr "函式 :func:`asyncio.sleep`。" #: ../../library/asyncio-eventloop.rst:341 msgid "Creating Futures and Tasks" -msgstr "" +msgstr "建立 Futures 和 Tasks" #: ../../library/asyncio-eventloop.rst:345 msgid "Create an :class:`asyncio.Future` object attached to the event loop." -msgstr "" +msgstr "建立附加到事件迴圈的 :class:`asyncio.Future` 物件。" #: ../../library/asyncio-eventloop.rst:347 msgid "" @@ -466,12 +538,14 @@ msgid "" "party event loops provide alternative implementations of the Future object " "(with better performance or instrumentation)." msgstr "" +"這是在 asyncio 中建立 Futures 的首選方式。這允許第三方事件迴圈提供 Future 物" +"件的替代實作(具有更好的性能或儀器計測表現)。" #: ../../library/asyncio-eventloop.rst:355 msgid "" "Schedule the execution of :ref:`coroutine ` *coro*. Return a :" "class:`Task` object." -msgstr "" +msgstr "排程執行\\ :ref:`協程 ` *coro*。回傳 :class:`Task` 物件。" #: ../../library/asyncio-eventloop.rst:358 msgid "" @@ -479,12 +553,16 @@ msgid "" "interoperability. In this case, the result type is a subclass of :class:" "`Task`." msgstr "" +"第三方事件迴圈可以使用其自己的 :class:`Task` 子類別以實現互操作性" +"(interoperability)。在這種情況下,結果類型是 :class:`Task` 的子類別。" #: ../../library/asyncio-eventloop.rst:362 msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." msgstr "" +"如果提供了 *name* 引數且不為 ``None``,則將其設置為任務的名稱,使用 :meth:" +"`Task.set_name`。" #: ../../library/asyncio-eventloop.rst:365 msgid "" @@ -492,6 +570,9 @@ msgid "" "class:`contextvars.Context` for the *coro* to run in. The current context " "copy is created when no *context* is provided." msgstr "" +"可選的僅限關鍵字 *context* 引數允許為 *coro* 指定自定義的 :class:" +"`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立當前情境的副" +"本。" #: ../../library/asyncio-eventloop.rst:369 msgid "Added the *name* parameter." @@ -503,7 +584,7 @@ msgstr "加入 *context* 參數。" #: ../../library/asyncio-eventloop.rst:377 msgid "Set a task factory that will be used by :meth:`loop.create_task`." -msgstr "" +msgstr "設置將由 :meth:`loop.create_task` 使用的任務工廠。" #: ../../library/asyncio-eventloop.rst:380 msgid "" @@ -513,20 +594,24 @@ msgid "" "*coro* is a coroutine object. The callable must return a :class:`asyncio." "Future`-compatible object." msgstr "" +"如果 *factory* 為 ``None``,將設置預設的任務工廠。否則,*factory* 必須是一個" +"具有匹配簽名 ``(loop, coro, context=None)`` 的 *callable*,其中 *loop* 是有效" +"事件迴圈的參照,*coro* 是一個協程物件。該可呼叫物件必須回傳一個與 :class:" +"`asyncio.Future` 相容的物件。" #: ../../library/asyncio-eventloop.rst:388 msgid "Return a task factory or ``None`` if the default one is in use." -msgstr "" +msgstr "回傳任務工廠,如果使用預設任務工廠則回傳 ``None``。" #: ../../library/asyncio-eventloop.rst:392 msgid "Opening network connections" -msgstr "" +msgstr "打開網路連線" #: ../../library/asyncio-eventloop.rst:403 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." -msgstr "" +msgstr "打開以 *host* 和 *port* 指定之給定地址的串流傳輸連線。" #: ../../library/asyncio-eventloop.rst:406 msgid "" @@ -534,10 +619,12 @@ msgid "" "`~socket.AF_INET6` depending on *host* (or the *family* argument, if " "provided)." msgstr "" +"根據 *host*(或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" +"`~socket.AF_INET` 或 :py:const:`~socket.AF_INET6`。" #: ../../library/asyncio-eventloop.rst:410 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." -msgstr "" +msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" #: ../../library/asyncio-eventloop.rst:412 #: ../../library/asyncio-eventloop.rst:1156 @@ -546,48 +633,55 @@ msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." msgstr "" +"*protocol_factory* 必須是一個回傳 :ref:`asyncio protocol " +"` 實作的可呼叫函式。" #: ../../library/asyncio-eventloop.rst:415 msgid "" "This method will try to establish the connection in the background. When " "successful, it returns a ``(transport, protocol)`` pair." msgstr "" +"此方法將嘗試在背景建立連線。成功時,它將回傳一對 ``(transport, protocol)``。" #: ../../library/asyncio-eventloop.rst:418 msgid "The chronological synopsis of the underlying operation is as follows:" -msgstr "" +msgstr "底層操作的時間軸簡介如下:" #: ../../library/asyncio-eventloop.rst:420 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." -msgstr "" +msgstr "建立連線並為其建立\\ :ref:`傳輸 `。" #: ../../library/asyncio-eventloop.rst:423 msgid "" "*protocol_factory* is called without arguments and is expected to return a :" "ref:`protocol ` instance." msgstr "" +"*protocol_factory* 在無引數的情況下被呼叫,並且預計回傳一個 :ref:`協定 " +"` 實例。" #: ../../library/asyncio-eventloop.rst:426 msgid "" "The protocol instance is coupled with the transport by calling its :meth:" "`~BaseProtocol.connection_made` method." msgstr "" +"通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協議實例與傳輸連線在" +"一起。" #: ../../library/asyncio-eventloop.rst:429 msgid "A ``(transport, protocol)`` tuple is returned on success." -msgstr "" +msgstr "成功時回傳一個 ``(transport, protocol)`` 元組。" #: ../../library/asyncio-eventloop.rst:431 msgid "" "The created transport is an implementation-dependent bidirectional stream." -msgstr "" +msgstr "建立的傳輸是一個依賴實作的雙向串流。" #: ../../library/asyncio-eventloop.rst:434 #: ../../library/asyncio-eventloop.rst:566 msgid "Other arguments:" -msgstr "" +msgstr "其他引數:" #: ../../library/asyncio-eventloop.rst:436 msgid "" @@ -597,10 +691,13 @@ msgid "" "`True`, a default context returned from :func:`ssl.create_default_context` " "is used." msgstr "" +"若有給定 *ssl* 且非 false,將建立 SSL/TLS 傳輸(預設建立普通 TCP 傳輸)。如" +"果 *ssl* 為 :class:`ssl.SSLContext` 物件,則使用該情境來建立傳輸;如果 *ssl* " +"為 :const:`True`,則使用 :func:`ssl.create_default_context` 回傳的預設情境。" #: ../../library/asyncio-eventloop.rst:442 msgid ":ref:`SSL/TLS security considerations `" -msgstr "" +msgstr ":ref:`SSL/TLS 安全考量 `" #: ../../library/asyncio-eventloop.rst:444 msgid "" @@ -612,6 +709,10 @@ msgid "" "matching is disabled (which is a serious security risk, allowing for " "potential man-in-the-middle attacks)." msgstr "" +"*server_hostname* 設置或覆蓋目標伺服器憑證將匹配的主機名稱。僅在 *ssl* 不為 " +"``None`` 時傳遞。預設情況下,將使用 *host* 引數的值。如果 *host* 為空,則沒有" +"預設值,必須傳遞 *server_hostname* 的值。若 *server_hostname* 為空字串,將停" +"用主機名稱匹配(這是一個嚴重的安全風險,可能導致中間人攻擊)。" #: ../../library/asyncio-eventloop.rst:452 msgid "" @@ -620,6 +721,9 @@ msgid "" "these should all be integers from the corresponding :mod:`socket` module " "constants." msgstr "" +"*family*、*proto*、*flags* 是可選的位址家族、協議和旗標,用於傳遞至 " +"getaddrinfo() 進行 *host* 解析。若有給定這些應該都是相應 :mod:`socket` 模組常" +"數的整數。" #: ../../library/asyncio-eventloop.rst:457 msgid "" @@ -630,6 +734,10 @@ msgid "" "Delay\" as defined in :rfc:`8305`. A sensible default value recommended by " "the RFC is ``0.25`` (250 milliseconds)." msgstr "" +"若有給定,*happy_eyeballs_delay* 會啟用此連線的 Happy Eyeballs。它應該是一個" +"浮點數,表示等待連線嘗試完成的秒數,然後在並行啟動下一次嘗試。這是 :rfc:" +"`8305` 中定義的「連線嘗試延遲」。RFC 建議的合理預設值為 ``0.25`` 秒(250 毫" +"秒)。" #: ../../library/asyncio-eventloop.rst:465 msgid "" @@ -641,6 +749,11 @@ msgid "" "Count\" as defined in :rfc:`8305`. The default is ``0`` if " "*happy_eyeballs_delay* is not specified, and ``1`` if it is." msgstr "" +"*interleave* 控制主機名稱解析為多個 IP 位址時的地址重新排序。若為 ``0`` 或未" +"指定,將不執行重排序,並按 :meth:`getaddrinfo` 回傳的順序嘗試位址。如果指定正" +"整數,則按地址家族交錯排列,給定的整數直譯為 :rfc:`8305` 中定義的「首個地址家" +"族計數」。如果未指定 *happy_eyeballs_delay*,則預設值為 ``0``,如果指定則為 " +"``1``。" #: ../../library/asyncio-eventloop.rst:474 msgid "" @@ -649,6 +762,9 @@ msgid "" "*host*, *port*, *family*, *proto*, *flags*, *happy_eyeballs_delay*, " "*interleave* and *local_addr* should be specified." msgstr "" +"若有給定 *sock* 則其應為已存在且已連線的 :class:`socket.socket` 物件,可供傳" +"輸使用。如果提供了 *sock*,則不應指定 *host*、*port*、*family*、*proto*、" +"*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" #: ../../library/asyncio-eventloop.rst:482 #: ../../library/asyncio-eventloop.rst:597 @@ -658,6 +774,8 @@ msgid "" "created. To close the socket, call the transport's :meth:`~asyncio." "BaseTransport.close` method." msgstr "" +"引數 *sock* 將 socket 所有權轉移給所建立的傳輸 socket,請呼叫傳輸的 :meth:" +"`~asyncio.BaseTransport.close` 方法。" #: ../../library/asyncio-eventloop.rst:486 msgid "" @@ -665,6 +783,9 @@ msgid "" "the socket locally. The *local_host* and *local_port* are looked up using " "``getaddrinfo()``, similarly to *host* and *port*." msgstr "" +"若有給定 *local_addr* 則其為一個 ``(local_host, local_port)`` 元組,用於在本" +"地綁定 socket。將使用 ``getaddrinfo()`` 查找 *local_host* 和 *local_port*,方" +"式類似於 *host* 和 *port*。" #: ../../library/asyncio-eventloop.rst:490 #: ../../library/asyncio-eventloop.rst:919 @@ -673,6 +794,9 @@ msgid "" "wait for the TLS handshake to complete before aborting the connection. " "``60.0`` seconds if ``None`` (default)." msgstr "" +"*ssl_handshake_timeout* (對於 TLS 連線)是等待 TLS 交握的時間,以秒為單位," +"在那之前若未完成則會中斷連線。如果為 ``None`` (預設值),則會等待 ``60.0`` " +"秒。" #: ../../library/asyncio-eventloop.rst:494 #: ../../library/asyncio-eventloop.rst:742 @@ -683,6 +807,8 @@ msgid "" "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" +"*ssl_shutdown_timeout* 是等待 SSL 關閉完成以前中斷連線的時間,以秒為單位。如" +"果為 ``None`` (預設值),則會等待 ``30.0`` 秒。" #: ../../library/asyncio-eventloop.rst:498 msgid "" @@ -693,6 +819,10 @@ msgid "" "``True``, an ``ExceptionGroup`` will be raised containing all exceptions " "(even if there is only one)." msgstr "" +"*all_errors* 決定在無法建立連線時會引發哪些例外。預設情況下,只會引發單一 " +"``Exception``:如果只有一個例外或所有錯誤訊息相同,則引發第一個例外,否則引發" +"包含所有錯誤訊息的單一 ``OSError``。當 ``all_errors`` 為 ``True`` 時,將引發" +"包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" #: ../../library/asyncio-eventloop.rst:508 #: ../../library/asyncio-eventloop.rst:754 @@ -726,6 +856,11 @@ msgid "" "This document specifies requirements for algorithms that reduce this user-" "visible delay and provides an algorithm." msgstr "" +"Happy Eyeballs 演算法:雙協定堆疊主機 (Dual-Stack Hosts) 的成功。當伺服器的 " +"IPv4 路徑和協議運作正常,但伺服器的 IPv6 路徑和協議不運作時,雙棧用戶端應用程" +"式會比僅具 IPv4 的用戶端體驗到顯著的連線延遲。這是不希望的,因為這會導致雙棧" +"用戶端的使用者體驗變差。本文件具體說明了減少此用戶可見延遲的演算法要求並提供" +"了一種演算法。" #: ../../library/asyncio-eventloop.rst:532 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" @@ -742,7 +877,7 @@ msgstr "增加 *ssl_shutdown_timeout* 參數。" #: ../../library/asyncio-eventloop.rst:538 msgid "*all_errors* was added." -msgstr "" +msgstr "已新增 *all_errors*。" #: ../../library/asyncio-eventloop.rst:543 msgid "" @@ -750,10 +885,12 @@ msgid "" "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " "used directly in async/await code." msgstr "" +"函式 :func:`open_connection` 是高階的替代 API。它回傳一對 (:class:" +"`StreamReader`, :class:`StreamWriter`) 可直接在 async/await 程式碼中使用。" #: ../../library/asyncio-eventloop.rst:553 msgid "Create a datagram connection." -msgstr "" +msgstr "建立一個資料報連線。" #: ../../library/asyncio-eventloop.rst:555 msgid "" @@ -761,10 +898,13 @@ msgid "" "`~socket.AF_INET6`, or :py:const:`~socket.AF_UNIX`, depending on *host* (or " "the *family* argument, if provided)." msgstr "" +"Socket 家族可以是 :py:const:`~socket.AF_INET`、:py:const:`~socket.AF_INET6` " +"或 :py:const:`~socket.AF_UNIX`,視乎 *host*\\ (或提供的 *family* 引數)而" +"定。" #: ../../library/asyncio-eventloop.rst:559 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." -msgstr "" +msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" #: ../../library/asyncio-eventloop.rst:561 #: ../../library/asyncio-eventloop.rst:685 @@ -773,11 +913,13 @@ msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." msgstr "" +"*protocol_factory* 必須是可呼叫的函式,回傳 :ref:`protocol ` 實作。" #: ../../library/asyncio-eventloop.rst:564 #: ../../library/asyncio-eventloop.rst:642 msgid "A tuple of ``(transport, protocol)`` is returned on success." -msgstr "" +msgstr "成功時回傳 ``(transport, protocol)`` 元組。" #: ../../library/asyncio-eventloop.rst:568 msgid "" @@ -785,6 +927,8 @@ msgid "" "the socket locally. The *local_host* and *local_port* are looked up using :" "meth:`getaddrinfo`." msgstr "" +"*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" +"綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" #: ../../library/asyncio-eventloop.rst:572 msgid "" @@ -792,6 +936,9 @@ msgid "" "connect the socket to a remote address. The *remote_host* and *remote_port* " "are looked up using :meth:`getaddrinfo`." msgstr "" +"*remote_addr*,如果提供,是一個 ``(remote_host, remote_port)`` 元組,用於將 " +"socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:`getaddrinfo` " +"來查找。" #: ../../library/asyncio-eventloop.rst:576 msgid "" @@ -800,6 +947,9 @@ msgid "" "given, these should all be integers from the corresponding :mod:`socket` " "module constants." msgstr "" +"*family*、*proto* 和 *flags* 是用於傳遞給 :meth:`getaddrinfo` 以解析 *host* " +"的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" +"組常數的整數。" #: ../../library/asyncio-eventloop.rst:581 msgid "" @@ -809,12 +959,15 @@ msgid "" "Unixes. If the :ref:`socket.SO_REUSEPORT ` constant " "is not defined then this capability is unsupported." msgstr "" +"*reuse_port* 告訴核心允許將此端點綁定到與其他現有端點相同的埠,只要它們在建立" +"時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" +"const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" #: ../../library/asyncio-eventloop.rst:587 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." -msgstr "" +msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" #: ../../library/asyncio-eventloop.rst:590 msgid "" @@ -823,18 +976,25 @@ msgid "" "specified, *local_addr* and *remote_addr* should be omitted (must be :const:" "`None`)." msgstr "" +"*sock* 可以選擇性地指定,以使用預先存在且已連線的 :class:`socket.socket` 物件" +"供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" +"`None`\\ )。" #: ../../library/asyncio-eventloop.rst:601 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." msgstr "" +"請參閱 :ref:`UDP 回應用戶端協議 ` 和 :ref:" +"`UDP 回應伺服器協議 ` 範例。" #: ../../library/asyncio-eventloop.rst:604 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." msgstr "" +"新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" +"*allow_broadcast* 和 *sock* 參數。" #: ../../library/asyncio-eventloop.rst:608 msgid "Added support for Windows." @@ -846,6 +1006,8 @@ msgid "" "SO_REUSEADDR ` poses a significant security concern " "for UDP. Explicitly passing ``reuse_address=True`` will raise an exception." msgstr "" +"不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" +"於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" #: ../../library/asyncio-eventloop.rst:617 msgid "" @@ -853,6 +1015,8 @@ msgid "" "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " "randomly distributed among the sockets." msgstr "" +"當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " +"socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" #: ../../library/asyncio-eventloop.rst:621 msgid "" @@ -861,22 +1025,28 @@ msgid "" "unix-constants>` is used instead, which specifically prevents processes with " "differing UIDs from assigning sockets to the same socket address." msgstr "" +"對於有支援的平台,*reuse_port* 可以用作類似功能的替代方案。使用 " +"*reuse_port*,將改為使用 :py:const:`~sockets.SO_REUSEPORT`,該選項明確禁止具" +"有不同 UID 的行程將 socket 分配給相同的 socket 地址。" #: ../../library/asyncio-eventloop.rst:628 msgid "" "The *reuse_address* parameter, disabled since Python 3.8.1, 3.7.6 and " "3.6.10, has been entirely removed." msgstr "" +"自 Python 3.9.0、3.8.1、3.7.6 和 3.6.10 起,已完全移除 *reuse_address* 參數。" #: ../../library/asyncio-eventloop.rst:637 msgid "Create a Unix connection." -msgstr "" +msgstr "建立一個 Unix 連線。" #: ../../library/asyncio-eventloop.rst:639 msgid "" "The socket family will be :py:const:`~socket.AF_UNIX`; socket type will be :" "py:const:`~socket.SOCK_STREAM`." msgstr "" +"Socket 家族將為 :py:const:`~socket.AF_UNIX`;socket 類型將為 :py:const:" +"`~socket.SOCK_STREAM`。" #: ../../library/asyncio-eventloop.rst:644 msgid "" @@ -884,12 +1054,15 @@ msgid "" "parameter is specified. Abstract Unix sockets, :class:`str`, :class:" "`bytes`, and :class:`~pathlib.Path` paths are supported." msgstr "" +"*path* 是 Unix 域 socket 的名稱,除非指定 *sock* 參數,否則為必填。支援抽象 " +"Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路徑。" #: ../../library/asyncio-eventloop.rst:649 msgid "" "See the documentation of the :meth:`loop.create_connection` method for " "information about arguments to this method." msgstr "" +"有關此方法的引數資訊,請參閱 :meth:`loop.create_connection` 方法的文件。" #: ../../library/asyncio-eventloop.rst:652 #: ../../library/asyncio-eventloop.rst:794 @@ -902,20 +1075,24 @@ msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`." msgstr "" +"新增 *ssl_handshake_timeout* 參數。*path* 參數現在可以是 :term:`path-like " +"object`。" #: ../../library/asyncio-eventloop.rst:664 msgid "Creating network servers" -msgstr "" +msgstr "建立網路伺服器" #: ../../library/asyncio-eventloop.rst:678 msgid "" "Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening on " "*port* of the *host* address." msgstr "" +"建立一個 TCP 伺服器(socket 類型 :const:`~socket.SOCK_STREAM`\\ ),監聽 " +"*host* 位址的 *port*。" #: ../../library/asyncio-eventloop.rst:681 msgid "Returns a :class:`Server` object." -msgstr "" +msgstr "回傳一個 :class:`Server` 物件。" #: ../../library/asyncio-eventloop.rst:683 msgid "Arguments:" @@ -925,19 +1102,19 @@ msgstr "引數:" msgid "" "The *host* parameter can be set to several types which determine where the " "server would be listening:" -msgstr "" +msgstr "可以將 *host* 參數設為幾種類型,以確定伺服器將監聽的位置:" #: ../../library/asyncio-eventloop.rst:691 msgid "" "If *host* is a string, the TCP server is bound to a single network interface " "specified by *host*." -msgstr "" +msgstr "如果 *host* 是字串,則 TCP 伺服器綁定到由 *host* 指定的單個網路介面。" #: ../../library/asyncio-eventloop.rst:694 msgid "" "If *host* is a sequence of strings, the TCP server is bound to all network " "interfaces specified by the sequence." -msgstr "" +msgstr "如果 *host* 是字串序列,則 TCP 伺服器綁定到序列指定的所有網路介面。" #: ../../library/asyncio-eventloop.rst:697 msgid "" @@ -945,6 +1122,8 @@ msgid "" "list of multiple sockets will be returned (most likely one for IPv4 and " "another one for IPv6)." msgstr "" +"若 *host* 是空字串或 ``None``,則所有介面都被假定並回傳多個 socket 的清單(可" +"能一個用於 IPv4,另一個用於 IPv6)。" #: ../../library/asyncio-eventloop.rst:701 msgid "" @@ -953,6 +1132,9 @@ msgid "" "selected (note that if *host* resolves to multiple network interfaces, a " "different random port will be selected for each interface)." msgstr "" +"可以設定 *port* 參數以指定伺服器應該監聽的埠。如果是 ``0`` 或 ``None``\\ (預" +"設值),將隨機選擇一個未使用的埠(請注意,如果 *host* 解析為多個網路介" +"面,將為每個介面隨機選擇不同的隨機埠)。" #: ../../library/asyncio-eventloop.rst:706 msgid "" @@ -960,34 +1142,44 @@ msgid "" "AF_INET6` to force the socket to use IPv4 or IPv6. If not set, the *family* " "will be determined from host name (defaults to :const:`~socket.AF_UNSPEC`)." msgstr "" +"*family* 可以設定為 :const:`socket.AF_INET` 或 :const:`~socket.AF_INET6` 以強" +"制使用 IPv4 或 IPv6。如果未設定,*family* 將從主機名稱決定(預設為 :const:" +"`~socket.AF_UNSPEC`\\ )。" #: ../../library/asyncio-eventloop.rst:711 msgid "*flags* is a bitmask for :meth:`getaddrinfo`." -msgstr "" +msgstr "*flags* 是 :meth:`getaddrinfo` 的位元遮罩。" #: ../../library/asyncio-eventloop.rst:713 msgid "" "*sock* can optionally be specified in order to use a preexisting socket " "object. If specified, *host* and *port* must not be specified." msgstr "" +"可以可選地指定 *sock* 以使用現有的 socket 物件。如果指定了,*host* 和 *port* " +"不能指定。" #: ../../library/asyncio-eventloop.rst:718 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." msgstr "" +"*sock* 引數將 socket 的所有權轉移給建立的伺服器。要關閉 socket,請呼叫伺服器" +"的 :meth:`~asyncio.Server.close` 方法。" #: ../../library/asyncio-eventloop.rst:722 msgid "" "*backlog* is the maximum number of queued connections passed to :meth:" "`~socket.socket.listen` (defaults to 100)." msgstr "" +"*backlog* 是傳遞給 :meth:`~socket.socket.listen` 的最大佇列連線數(預設為 " +"100)。" #: ../../library/asyncio-eventloop.rst:725 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` instance to enable TLS over " "the accepted connections." msgstr "" +"*ssl* 可以設定為 :class:`~ssl.SSLContext` 實例以在接受的連線上啟用 TLS。" #: ../../library/asyncio-eventloop.rst:728 msgid "" @@ -995,6 +1187,8 @@ msgid "" "state, without waiting for its natural timeout to expire. If not specified " "will automatically be set to ``True`` on Unix." msgstr "" +"*reuse_address* 告訴內核重用 ``TIME_WAIT`` 狀態下的本地 socket,而不等待其自然" +"超時過期。如果未指定,在 Unix 上將自動設置為 ``True``。" #: ../../library/asyncio-eventloop.rst:733 msgid "" @@ -1002,6 +1196,8 @@ msgid "" "port as other existing endpoints are bound to, so long as they all set this " "flag when being created. This option is not supported on Windows." msgstr "" +"*reuse_port* 告訴內核允許此端點繫結到與其他現有端點繫結的相同埠,只要它們在建" +"立時都設置了此旗標。此選項在旗標 Windows 上不受支援。" #: ../../library/asyncio-eventloop.rst:738 msgid "" @@ -1009,6 +1205,8 @@ msgid "" "for the TLS handshake to complete before aborting the connection. ``60.0`` " "seconds if ``None`` (default)." msgstr "" +"(對於 TLS 伺服器)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 TLS 握手完" +"成的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" #: ../../library/asyncio-eventloop.rst:746 msgid "" @@ -1017,10 +1215,13 @@ msgid "" "should await on :meth:`Server.start_serving` or :meth:`Server.serve_forever` " "to make the server to start accepting connections." msgstr "" +"將 *start_serving* 設置為 ``True``\\ (預設)將使建立的伺服器立即開始接受連" +"接。當設置為 ``False`` 時,用戶應該等待 :meth:`Server.start_serving` 或 :" +"meth:`Server.serve_forever` 來使伺服器開始接受連線。" #: ../../library/asyncio-eventloop.rst:758 msgid "The *host* parameter can be a sequence of strings." -msgstr "" +msgstr "*host* 參數可以是字串序列。" #: ../../library/asyncio-eventloop.rst:762 msgid "" @@ -1037,12 +1238,16 @@ msgid "" "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " "be used in an async/await code." msgstr "" +":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" +"`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" #: ../../library/asyncio-eventloop.rst:783 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." msgstr "" +"類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " +"家族。" #: ../../library/asyncio-eventloop.rst:786 msgid "" @@ -1050,30 +1255,32 @@ msgid "" "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " "and :class:`~pathlib.Path` paths are supported." msgstr "" +"*path* 是 Unix 域 socket 的名稱,除非提供了 *sock* 引數,否則必須給定。支援抽象 " +"Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路徑。" #: ../../library/asyncio-eventloop.rst:791 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." -msgstr "" +msgstr "有關此方法的引數資訊,請參閱 :meth:`loop.create_server` 方法的文件。" #: ../../library/asyncio-eventloop.rst:798 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." msgstr "" -"新增 *ssl_handshake_timeout* 與 *start_serving* 參數。\\ *path* 參數現在可為" -"一個 :class:`~pathlib.Path` 物件。" +"新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" +"個 :class:`~pathlib.Path` 物件。" #: ../../library/asyncio-eventloop.rst:810 msgid "Wrap an already accepted connection into a transport/protocol pair." -msgstr "" +msgstr "將已接受的連線包裝成傳輸層/協議對。" #: ../../library/asyncio-eventloop.rst:812 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." -msgstr "" +msgstr "此方法可以由在 asyncio 外接受連線但使用 asyncio 處理連線的伺服器使用。" #: ../../library/asyncio-eventloop.rst:815 #: ../../library/asyncio-eventloop.rst:905 @@ -1085,12 +1292,14 @@ msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." msgstr "" +"*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " +"socket 物件。" #: ../../library/asyncio-eventloop.rst:829 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." -msgstr "" +msgstr "*ssl* 可以設置為 :class:`~ssl.SSLContext` 以在已接受的連線上啟用 SSL。" #: ../../library/asyncio-eventloop.rst:832 msgid "" @@ -1098,27 +1307,29 @@ msgid "" "wait for the SSL handshake to complete before aborting the connection. " "``60.0`` seconds if ``None`` (default)." msgstr "" +"(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" +"的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" #: ../../library/asyncio-eventloop.rst:840 msgid "Returns a ``(transport, protocol)`` pair." -msgstr "" +msgstr "回傳 ``(transport, protocol)`` 對。" #: ../../library/asyncio-eventloop.rst:854 msgid "Transferring files" -msgstr "" +msgstr "傳輸檔案" #: ../../library/asyncio-eventloop.rst:859 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." -msgstr "" +msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" #: ../../library/asyncio-eventloop.rst:862 msgid "The method uses high-performance :meth:`os.sendfile` if available." -msgstr "" +msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" #: ../../library/asyncio-eventloop.rst:864 msgid "*file* must be a regular file object opened in binary mode." -msgstr "" +msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" #: ../../library/asyncio-eventloop.rst:866 #: ../../library/asyncio-eventloop.rst:1111 @@ -1129,6 +1340,9 @@ msgid "" "raises an error, and :meth:`file.tell() ` can be used to " "obtain the actual number of bytes sent." msgstr "" +"*offset* 告訴從哪裡開始讀取檔案。如果指定了,*count* 是要傳輸的總位元組數,而" +"不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" +"用 :meth:`file.tell() ` 取得實際發送的位元組數。" #: ../../library/asyncio-eventloop.rst:873 msgid "" @@ -1136,20 +1350,24 @@ msgid "" "when the platform does not support the sendfile system call (e.g. Windows or " "SSL socket on Unix)." msgstr "" +"將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" +"(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" #: ../../library/asyncio-eventloop.rst:877 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." msgstr "" +"如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" +"`SendfileNotAvailableError`。" #: ../../library/asyncio-eventloop.rst:884 msgid "TLS Upgrade" -msgstr "" +msgstr "TLS 升級" #: ../../library/asyncio-eventloop.rst:891 msgid "Upgrade an existing transport-based connection to TLS." -msgstr "" +msgstr "將基於傳輸的現有連線升級到 TLS。" #: ../../library/asyncio-eventloop.rst:893 msgid "" @@ -1157,6 +1375,8 @@ msgid "" "and the *protocol*. The coder/decoder implements both *transport*-facing " "protocol and *protocol*-facing transport." msgstr "" +"建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" +"作了對於 *transport* 的協議,也實作了對於 *protocol* 的傳輸。" #: ../../library/asyncio-eventloop.rst:897 msgid "" @@ -1165,56 +1385,69 @@ msgid "" "object only because the coder caches *protocol*-side data and sporadically " "exchanges extra TLS session packets with *transport*." msgstr "" +"回傳建立的雙介面實例。在 *await* 後,*protocol* 必須停止使用原始的 " +"*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" +"與 *transport* 間歇性地交換額外的 TLS session 封包。" #: ../../library/asyncio-eventloop.rst:902 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." -msgstr "" +msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" #: ../../library/asyncio-eventloop.rst:907 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." msgstr "" +"*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" +"`~loop.create_connection` 等方法回傳。" #: ../../library/asyncio-eventloop.rst:911 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." -msgstr "" +msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" #: ../../library/asyncio-eventloop.rst:913 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." msgstr "" +"當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " +"``True``。" #: ../../library/asyncio-eventloop.rst:916 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." -msgstr "" +msgstr "*server_hostname*:設置或覆蓋將用於匹配目標伺服器憑證的主機名。" #: ../../library/asyncio-eventloop.rst:936 msgid "Watching file descriptors" -msgstr "" +msgstr "監視檔案描述器" #: ../../library/asyncio-eventloop.rst:940 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." msgstr "" +"開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數呼叫 " +"*callback*。" #: ../../library/asyncio-eventloop.rst:946 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." msgstr "" +"停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " +"``True``。" #: ../../library/asyncio-eventloop.rst:951 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." msgstr "" +"開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數呼叫 " +"*callback*。" #: ../../library/asyncio-eventloop.rst:955 #: ../../library/asyncio-eventloop.rst:1212 @@ -1222,22 +1455,27 @@ msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." msgstr "" +"使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" #: ../../library/asyncio-eventloop.rst:960 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." msgstr "" +"停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " +"``True``。" #: ../../library/asyncio-eventloop.rst:963 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." msgstr "" +"另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的一些" +"限制。" #: ../../library/asyncio-eventloop.rst:968 msgid "Working with socket objects directly" -msgstr "" +msgstr "直接使用 socket 物件" #: ../../library/asyncio-eventloop.rst:970 msgid "" @@ -1247,16 +1485,21 @@ msgid "" "cases when performance is not critical, and working with :class:`~socket." "socket` objects directly is more convenient." msgstr "" +"一般情況下,使用基於傳輸的 API(如 :meth:`loop.create_connection` 和 :meth:" +"`loop.create_server`\\ )的協議實作比直接使用 socket 的實作更快。然而在某些" +"情況下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" #: ../../library/asyncio-eventloop.rst:979 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." msgstr "" +"從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" +"同步版本。" #: ../../library/asyncio-eventloop.rst:982 msgid "Return the received data as a bytes object." -msgstr "" +msgstr "將接收到的資料作為 bytes 物件回傳。" #: ../../library/asyncio-eventloop.rst:984 #: ../../library/asyncio-eventloop.rst:998 @@ -1268,7 +1511,7 @@ msgstr "" #: ../../library/asyncio-eventloop.rst:1087 #: ../../library/asyncio-eventloop.rst:1125 msgid "*sock* must be a non-blocking socket." -msgstr "" +msgstr "*sock* 必須是非阻塞 socket。" #: ../../library/asyncio-eventloop.rst:986 msgid "" @@ -1276,42 +1519,52 @@ msgid "" "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " "is an ``async def`` method." msgstr "" +"儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" +"自 Python 3.7 起,這是 ``async def`` 方法。" #: ../../library/asyncio-eventloop.rst:993 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." msgstr "" +"從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " +"` 方法。" #: ../../library/asyncio-eventloop.rst:996 msgid "Return the number of bytes written to the buffer." -msgstr "" +msgstr "回傳寫入緩衝區位元組的數目。" #: ../../library/asyncio-eventloop.rst:1004 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." msgstr "" +"從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " +"` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1007 msgid "Return a tuple of (received data, remote address)." -msgstr "" +msgstr "回傳一個元組 (received data, remote address)。" #: ../../library/asyncio-eventloop.rst:1015 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." msgstr "" +"從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." +"recvfrom_into() ` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1019 msgid "Return a tuple of (number of bytes received, remote address)." -msgstr "" +msgstr "回傳一個元組 (number of bytes received, remote address)。" #: ../../library/asyncio-eventloop.rst:1027 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." msgstr "" +"將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1030 msgid "" @@ -1321,6 +1574,9 @@ msgid "" "how much data, if any, was successfully processed by the receiving end of " "the connection." msgstr "" +"此方法將繼續發送到 socket,直到 *data* 中的所有資料都已發送或發生錯誤。成功時" +"回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" +"果有的話)。" #: ../../library/asyncio-eventloop.rst:1038 #: ../../library/asyncio-eventloop.rst:1089 @@ -1329,25 +1585,29 @@ msgid "" "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " "``async def`` method." msgstr "" +"儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" +"從 Python 3.7 開始,這是一個 ``async def`` 方法。" #: ../../library/asyncio-eventloop.rst:1045 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." msgstr "" +"從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1049 msgid "Return the number of bytes sent." -msgstr "" +msgstr "回傳發送的位元組數。" #: ../../library/asyncio-eventloop.rst:1057 msgid "Connect *sock* to a remote socket at *address*." -msgstr "" +msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" #: ../../library/asyncio-eventloop.rst:1059 msgid "" "Asynchronous version of :meth:`socket.connect() `." -msgstr "" +msgstr ":meth:`socket.connect() ` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1063 msgid "" @@ -1356,18 +1616,25 @@ msgid "" "inet_pton`. If not, :meth:`loop.getaddrinfo` will be used to resolve the " "*address*." msgstr "" +"不再需要解析 ``address``。``sock_connect`` 將嘗試透過呼叫 :func:`socket." +"inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." +"getaddrinfo` 解析 *address*。" #: ../../library/asyncio-eventloop.rst:1072 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." msgstr "" +":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " +"`。" #: ../../library/asyncio-eventloop.rst:1078 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." msgstr "" +"接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" +"法。" #: ../../library/asyncio-eventloop.rst:1081 msgid "" @@ -1376,31 +1643,36 @@ msgid "" "object usable to send and receive data on the connection, and *address* is " "the address bound to the socket on the other end of the connection." msgstr "" +"Socket 必須繫結到一個地址並偵聽連線。回傳值是一個 ``(conn, address)`` 對,其" +"中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連" +"接另一端對應的 socket 地址。" #: ../../library/asyncio-eventloop.rst:1096 msgid ":meth:`loop.create_server` and :func:`start_server`." -msgstr ":meth:`loop.create_server` 和 :func:`start_server`\\ 。" +msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" #: ../../library/asyncio-eventloop.rst:1101 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" +"如果可行,使用高性能 :mod:`os.sendfile` 發送檔案。回傳發送的總位元組數。" #: ../../library/asyncio-eventloop.rst:1104 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." -msgstr "" +msgstr ":meth:`socket.sendfile() ` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1106 msgid "" "*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." "socket`." msgstr "" +"*sock* 必須是非阻塞的 :const:`socket.SOCK_STREAM` :class:`~socket.socket`。" #: ../../library/asyncio-eventloop.rst:1109 msgid "*file* must be a regular file object open in binary mode." -msgstr "" +msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" #: ../../library/asyncio-eventloop.rst:1118 msgid "" @@ -1408,12 +1680,16 @@ msgid "" "file when the platform does not support the sendfile syscall (e.g. Windows " "or SSL socket on Unix)." msgstr "" +"當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" +"(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" #: ../../library/asyncio-eventloop.rst:1122 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." msgstr "" +"如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" +"`SendfileNotAvailableError`。" #: ../../library/asyncio-eventloop.rst:1131 msgid "DNS" @@ -1421,11 +1697,11 @@ msgstr "DNS" #: ../../library/asyncio-eventloop.rst:1136 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." -msgstr "" +msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1140 msgid "Asynchronous version of :meth:`socket.getnameinfo`." -msgstr "" +msgstr ":meth:`socket.getnameinfo` 的非同步版本。" #: ../../library/asyncio-eventloop.rst:1142 msgid "" @@ -1434,18 +1710,21 @@ msgid "" "class:`asyncio.Future` objects. Starting with Python 3.7 both methods are " "coroutines." msgstr "" +"*getaddrinfo* 和 *getnameinfo* 方法一直被記錄為回傳協程,但在 Python 3.7 之前" +"它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" +"協程。" #: ../../library/asyncio-eventloop.rst:1150 msgid "Working with pipes" -msgstr "" +msgstr "使用管道" #: ../../library/asyncio-eventloop.rst:1154 msgid "Register the read end of *pipe* in the event loop." -msgstr "" +msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" #: ../../library/asyncio-eventloop.rst:1159 msgid "*pipe* is a :term:`file-like object `." -msgstr "" +msgstr "*pipe* 是 :term:`類檔案物件 `。" #: ../../library/asyncio-eventloop.rst:1161 msgid "" @@ -1453,21 +1732,23 @@ msgid "" "`ReadTransport` interface and *protocol* is an object instantiated by the " "*protocol_factory*." msgstr "" +"回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" +"`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" #: ../../library/asyncio-eventloop.rst:1165 #: ../../library/asyncio-eventloop.rst:1181 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." -msgstr "" +msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" #: ../../library/asyncio-eventloop.rst:1170 msgid "Register the write end of *pipe* in the event loop." -msgstr "" +msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" #: ../../library/asyncio-eventloop.rst:1175 msgid "*pipe* is :term:`file-like object `." -msgstr "" +msgstr "*pipe* 是 :term:`file-like object `。" #: ../../library/asyncio-eventloop.rst:1177 msgid "" @@ -1475,25 +1756,29 @@ msgid "" "`WriteTransport` interface and *protocol* is an object instantiated by the " "*protocol_factory*." msgstr "" +"回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" +"`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" #: ../../library/asyncio-eventloop.rst:1186 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." msgstr "" +":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使" +"用 :class:`ProactorEventLoop`。" #: ../../library/asyncio-eventloop.rst:1191 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." -msgstr "" +msgstr ":meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` 方法。" #: ../../library/asyncio-eventloop.rst:1196 msgid "Unix signals" -msgstr "" +msgstr "Unix 訊號" #: ../../library/asyncio-eventloop.rst:1202 msgid "Set *callback* as the handler for the *signum* signal." -msgstr "" +msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" #: ../../library/asyncio-eventloop.rst:1204 msgid "" @@ -1502,45 +1787,54 @@ msgid "" "registered using :func:`signal.signal`, a callback registered with this " "function is allowed to interact with the event loop." msgstr "" +"該回呼將由 *loop* 呼叫,與該事件迴圈的其他排隊回呼和可運行的協程一起。與使" +"用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" +"件迴圈進行互動。" #: ../../library/asyncio-eventloop.rst:1209 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." msgstr "" +"如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" +"出 :exc:`RuntimeError`。" #: ../../library/asyncio-eventloop.rst:1215 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." -msgstr "" +msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中呼叫。" #: ../../library/asyncio-eventloop.rst:1220 msgid "Remove the handler for the *sig* signal." -msgstr "" +msgstr "移除 *sig* 訊號的處理程式。" #: ../../library/asyncio-eventloop.rst:1222 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." msgstr "" +"如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " +"``False``。" #: ../../library/asyncio-eventloop.rst:1229 msgid "The :mod:`signal` module." -msgstr "" +msgstr ":mod:`signal` 模組。" #: ../../library/asyncio-eventloop.rst:1233 msgid "Executing code in thread or process pools" -msgstr "" +msgstr "在執行緒池或行程池中執行程式碼" #: ../../library/asyncio-eventloop.rst:1237 msgid "Arrange for *func* to be called in the specified executor." -msgstr "" +msgstr "安排在指定的執行器中呼叫 *func*。" #: ../../library/asyncio-eventloop.rst:1239 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``." msgstr "" +"*executor* 引數應該是 :class:`concurrent.futures.Executor` 實例。如果 " +"*executor* 為 ``None``,則使用預設執行器。" #: ../../library/asyncio-eventloop.rst:1284 msgid "" @@ -1549,16 +1843,22 @@ msgid "" "used by :class:`~concurrent.futures.ProcessPoolExecutor`. See :ref:`Safe " "importing of main module `." msgstr "" +"請注意,由於 :mod:`multiprocessing`\\ (由 :class:`~concurrent.futures." +"ProcessPoolExecutor` 使用)的特殊性,選項 3 需要進入點保護(\\ ``if __name__ " +"== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" #: ../../library/asyncio-eventloop.rst:1289 msgid "This method returns a :class:`asyncio.Future` object." -msgstr "" +msgstr "此方法回傳 :class:`asyncio.Future` 物件。" #: ../../library/asyncio-eventloop.rst:1291 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." msgstr "" +"使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ " +"給 *func*。" #: ../../library/asyncio-eventloop.rst:1294 msgid "" @@ -1567,6 +1867,9 @@ msgid "" "executor (:class:`~concurrent.futures.ThreadPoolExecutor`) to set the " "default." msgstr "" +":meth:`loop.run_in_executor` 不再配置它建立的執行緒池執行器的 " +"``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." +"ThreadPoolExecutor`)設定預設值。" #: ../../library/asyncio-eventloop.rst:1303 msgid "" @@ -1574,24 +1877,27 @@ msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" +"將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" +"須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" #: ../../library/asyncio-eventloop.rst:1307 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" +"*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" #: ../../library/asyncio-eventloop.rst:1313 msgid "Error Handling API" -msgstr "" +msgstr "錯誤處理 API" #: ../../library/asyncio-eventloop.rst:1315 msgid "Allows customizing how exceptions are handled in the event loop." -msgstr "" +msgstr "允許自定義事件迴圈中的例外處理方式。" #: ../../library/asyncio-eventloop.rst:1319 msgid "Set *handler* as the new event loop exception handler." -msgstr "" +msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" #: ../../library/asyncio-eventloop.rst:1321 msgid "" @@ -1601,6 +1907,10 @@ msgid "" "``context`` is a ``dict`` object containing the details of the exception " "(see :meth:`call_exception_handler` documentation for details about context)." msgstr "" +"如果 *handler* 是 ``None``,則將設置預設例外處理程式。否則,*handler* 必須是" +"一個可呼叫物件,簽名匹配 ``(loop, context)``,其中 ``loop`` 是參照活躍事件迴" +"圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資" +"訊,請參閱 :meth:`call_exception_handler` 文件)。" #: ../../library/asyncio-eventloop.rst:1329 msgid "" @@ -1608,22 +1918,27 @@ msgid "" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " "task or callback handle." msgstr "" +"如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" +"將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" #: ../../library/asyncio-eventloop.rst:1335 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." msgstr "" +"處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" +"叫。" #: ../../library/asyncio-eventloop.rst:1340 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" +"回傳當前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" #: ../../library/asyncio-eventloop.rst:1347 msgid "Default exception handler." -msgstr "" +msgstr "預設例外處理程式。" #: ../../library/asyncio-eventloop.rst:1349 msgid "" @@ -1631,92 +1946,100 @@ msgid "" "This can be called by a custom exception handler that wants to defer to the " "default handler behavior." msgstr "" +"當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" +"以轉由預設處理程式處理。" #: ../../library/asyncio-eventloop.rst:1353 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." -msgstr "" +msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" #: ../../library/asyncio-eventloop.rst:1358 msgid "Call the current event loop exception handler." -msgstr "" +msgstr "呼叫當前事件迴圈例外處理程式。" #: ../../library/asyncio-eventloop.rst:1360 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" msgstr "" +"*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" +"的鍵):" #: ../../library/asyncio-eventloop.rst:1363 msgid "'message': Error message;" -msgstr "" +msgstr "'message':錯誤訊息;" #: ../../library/asyncio-eventloop.rst:1364 msgid "'exception' (optional): Exception object;" -msgstr "" +msgstr "'exception'(可選):例外物件;" #: ../../library/asyncio-eventloop.rst:1365 msgid "'future' (optional): :class:`asyncio.Future` instance;" -msgstr "" +msgstr "'future'(可選): :class:`asyncio.Future` 實例;" #: ../../library/asyncio-eventloop.rst:1366 msgid "'task' (optional): :class:`asyncio.Task` instance;" -msgstr "" +msgstr "'task'(可選): :class:`asyncio.Task` 實例;" #: ../../library/asyncio-eventloop.rst:1367 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" -msgstr "" +msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" #: ../../library/asyncio-eventloop.rst:1368 msgid "'protocol' (optional): :ref:`Protocol ` instance;" -msgstr "" +msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" #: ../../library/asyncio-eventloop.rst:1369 msgid "'transport' (optional): :ref:`Transport ` instance;" -msgstr "" +msgstr "'transport'(可選): :ref:`Transport ` 實例;" #: ../../library/asyncio-eventloop.rst:1370 msgid "'socket' (optional): :class:`socket.socket` instance;" -msgstr "" +msgstr "'socket'(可選): :class:`socket.socket` 實例;" #: ../../library/asyncio-eventloop.rst:1371 msgid "'asyncgen' (optional): Asynchronous generator that caused" -msgstr "" +msgstr "'asyncgen'(可選): 非同步產生器引發" #: ../../library/asyncio-eventloop.rst:1372 msgid "the exception." -msgstr "" +msgstr "例外。" #: ../../library/asyncio-eventloop.rst:1376 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler()` method." msgstr "" +"此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" +"`set_exception_handler()` 方法。" #: ../../library/asyncio-eventloop.rst:1381 msgid "Enabling debug mode" -msgstr "" +msgstr "啟用除錯模式" #: ../../library/asyncio-eventloop.rst:1385 msgid "Get the debug mode (:class:`bool`) of the event loop." -msgstr "" +msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" #: ../../library/asyncio-eventloop.rst:1387 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." msgstr "" +"如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " +"``True``,否則為 ``False``。" #: ../../library/asyncio-eventloop.rst:1393 msgid "Set the debug mode of the event loop." -msgstr "" +msgstr "設定事件迴圈的除錯模式。" #: ../../library/asyncio-eventloop.rst:1397 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." -msgstr "" +msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" #: ../../library/asyncio-eventloop.rst:1402 msgid "" @@ -1724,18 +2047,20 @@ msgid "" "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " "are logged." msgstr "" +"此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" +"後,\"慢\"回呼將被記錄。" #: ../../library/asyncio-eventloop.rst:1406 msgid "Default value is 100 milliseconds." -msgstr "" +msgstr "預設值為 100 毫秒" #: ../../library/asyncio-eventloop.rst:1410 msgid "The :ref:`debug mode of asyncio `." -msgstr "" +msgstr ":ref:`asyncio 的除錯模式 `。" #: ../../library/asyncio-eventloop.rst:1414 msgid "Running Subprocesses" -msgstr "" +msgstr "運行子行程" #: ../../library/asyncio-eventloop.rst:1416 msgid "" @@ -1743,6 +2068,9 @@ msgid "" "code consider using the high-level :func:`asyncio.create_subprocess_shell` " "and :func:`asyncio.create_subprocess_exec` convenience functions instead." msgstr "" +"本小節描述的方法是低階的。在常規的 async/await 程式碼中,請考慮使用高階 :" +"func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." +"create_subprocess_exec` 輔助功能而不是。" #: ../../library/asyncio-eventloop.rst:1423 msgid "" @@ -1750,25 +2078,28 @@ msgid "" "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" "`Subprocess Support on Windows ` for details." msgstr "" +"在 Windows 上,預設事件迴圈 :class:`ProactorEventLoop` 支援子行程,而 :class:" +"`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " +"`。" #: ../../library/asyncio-eventloop.rst:1434 msgid "" "Create a subprocess from one or more string arguments specified by *args*." -msgstr "" +msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" #: ../../library/asyncio-eventloop.rst:1437 msgid "*args* must be a list of strings represented by:" -msgstr "" +msgstr "*args* 必須是由以下項表示的字串串列:" #: ../../library/asyncio-eventloop.rst:1439 msgid ":class:`str`;" -msgstr ":class:`str`\\ ;" +msgstr ":class:`str`;" #: ../../library/asyncio-eventloop.rst:1440 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." -msgstr "" +msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" #: ../../library/asyncio-eventloop.rst:1443 msgid "" @@ -1776,6 +2107,8 @@ msgid "" "specify the arguments. Together, string arguments form the ``argv`` of the " "program." msgstr "" +"第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " +"``argv``。" #: ../../library/asyncio-eventloop.rst:1447 msgid "" @@ -1784,12 +2117,17 @@ msgid "" "argument; however, where :class:`~subprocess.Popen` takes a single argument " "which is list of strings, *subprocess_exec* takes multiple string arguments." msgstr "" +"這與標準函式庫 :class:`subprocess.Popen` 類似,使用 ``shell=False`` 呼叫並將" +"字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" +"引數,*subprocess_exec* 接受多個字串引數。" #: ../../library/asyncio-eventloop.rst:1453 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." msgstr "" +"*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" +"呼叫物件。" #: ../../library/asyncio-eventloop.rst:1456 msgid "Other parameters:" @@ -1797,19 +2135,19 @@ msgstr "其他參數:" #: ../../library/asyncio-eventloop.rst:1458 msgid "*stdin* can be any of these:" -msgstr "" +msgstr "*stdin* 可以是以下任意一個:" #: ../../library/asyncio-eventloop.rst:1460 #: ../../library/asyncio-eventloop.rst:1471 #: ../../library/asyncio-eventloop.rst:1481 msgid "a file-like object" -msgstr "" +msgstr "類檔案物件" #: ../../library/asyncio-eventloop.rst:1461 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe()`" -msgstr "" +msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe()` 建立的" #: ../../library/asyncio-eventloop.rst:1462 #: ../../library/asyncio-eventloop.rst:1472 @@ -1817,7 +2155,7 @@ msgstr "" msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," -msgstr "" +msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," #: ../../library/asyncio-eventloop.rst:1464 #: ../../library/asyncio-eventloop.rst:1474 @@ -1825,7 +2163,7 @@ msgstr "" msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" -msgstr "" +msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" #: ../../library/asyncio-eventloop.rst:1466 #: ../../library/asyncio-eventloop.rst:1476 @@ -1834,20 +2172,22 @@ msgid "" "the :const:`subprocess.DEVNULL` constant which indicates that the special :" "data:`os.devnull` file will be used" msgstr "" +":const:`subprocess.DEVNULL` 常數,表示將使用特殊的 :data:`os.devnull` 檔案" #: ../../library/asyncio-eventloop.rst:1469 msgid "*stdout* can be any of these:" -msgstr "" +msgstr "*stdout* 可以是以下任意一個:" #: ../../library/asyncio-eventloop.rst:1479 msgid "*stderr* can be any of these:" -msgstr "" +msgstr "*stderr* 可以是以下任意一個:" #: ../../library/asyncio-eventloop.rst:1488 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" +":const:`subprocess.STDOUT` 常數,它將標準錯誤串流連線到行程的標準輸出串流" #: ../../library/asyncio-eventloop.rst:1491 msgid "" @@ -1855,6 +2195,9 @@ msgid "" "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " "*encoding* and *errors*, which should not be specified at all." msgstr "" +"所有其他關鍵字引數都會傳遞給 :class:`subprocess.Popen` 而不進行直譯,但 " +"*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" +"外,這些不應該指定。" #: ../../library/asyncio-eventloop.rst:1496 msgid "" @@ -1862,6 +2205,8 @@ msgid "" "text. :func:`bytes.decode` can be used to convert the bytes returned from " "the stream to text." msgstr "" +"``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " +"將從串流回傳的位元組轉換為文本。" #: ../../library/asyncio-eventloop.rst:1500 msgid "" @@ -1870,12 +2215,15 @@ msgid "" "`~loop.connect_write_pipe` or :meth:`~loop.connect_read_pipe` for use with " "the event loop." msgstr "" +"如果傳遞給 *stdin*、*stdout* 或 *stderr* 的類檔案物件表示管道,則該管道的" +"另一端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." +"connect_read_pipe` 註冊到事件迴圈中。" #: ../../library/asyncio-eventloop.rst:1505 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." -msgstr "" +msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" #: ../../library/asyncio-eventloop.rst:1508 msgid "" @@ -1883,6 +2231,9 @@ msgid "" "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " "object instantiated by the *protocol_factory*." msgstr "" +"回傳 ``(transport, protocol)`` 對,其中 *transport* 符合 :class:`asyncio." +"SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" +"件。" #: ../../library/asyncio-eventloop.rst:1516 msgid "" @@ -1890,24 +2241,30 @@ msgid "" "`bytes` string encoded to the :ref:`filesystem encoding `, using the platform's \"shell\" syntax." msgstr "" +"使用平台的 “shell” 語法從 *cmd* 建立子行程,*cmd* 可以是 :class:`str` 或編碼" +"為 :ref:`檔案系統編碼 ` 的 :class:`bytes` 字串。" #: ../../library/asyncio-eventloop.rst:1521 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." msgstr "" +"這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" +"叫。" #: ../../library/asyncio-eventloop.rst:1524 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." msgstr "" +"*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" +"件。" #: ../../library/asyncio-eventloop.rst:1527 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." -msgstr "" +msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" #: ../../library/asyncio-eventloop.rst:1530 msgid "" @@ -1915,6 +2272,9 @@ msgid "" "the :class:`SubprocessTransport` base class and *protocol* is an object " "instantiated by the *protocol_factory*." msgstr "" +"回傳一對 ``(transport, protocol)``,其中 *transport* 符合 :class:" +"`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" +"的物件。" #: ../../library/asyncio-eventloop.rst:1535 msgid "" @@ -1925,55 +2285,60 @@ msgid "" "escape whitespace and special characters in strings that are going to be " "used to construct shell commands." msgstr "" +"由應用程式負責確保適當引用所有空白和特殊字元,以避免 `shell 注入 `_\\ 風險。可以使用 :func:" +"`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" #: ../../library/asyncio-eventloop.rst:1544 msgid "Callback Handles" -msgstr "" +msgstr "回呼處理" #: ../../library/asyncio-eventloop.rst:1548 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." msgstr "" +"由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" +"器。" #: ../../library/asyncio-eventloop.rst:1553 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." -msgstr "" +msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" #: ../../library/asyncio-eventloop.rst:1560 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." -msgstr "" +msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" #: ../../library/asyncio-eventloop.rst:1565 msgid "Return ``True`` if the callback was cancelled." -msgstr "" +msgstr "如果回呼已被取消,回傳 ``True``。" #: ../../library/asyncio-eventloop.rst:1571 msgid "" "A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" "`loop.call_at`." -msgstr "" +msgstr "由 :meth:`loop.call_later` 和 :meth:`loop.call_at` 回傳的回呼包裝器。" #: ../../library/asyncio-eventloop.rst:1574 msgid "This class is a subclass of :class:`Handle`." -msgstr "" +msgstr "這個類別是 :class:`Handle` 的子類別。" #: ../../library/asyncio-eventloop.rst:1578 msgid "Return a scheduled callback time as :class:`float` seconds." -msgstr "" +msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" #: ../../library/asyncio-eventloop.rst:1580 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." -msgstr "" +msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" #: ../../library/asyncio-eventloop.rst:1587 msgid "Server Objects" -msgstr "" +msgstr "Server 物件" #: ../../library/asyncio-eventloop.rst:1589 msgid "" @@ -1981,10 +2346,13 @@ msgid "" "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " "functions." msgstr "" +"Server 物件是由 :meth:`loop.create_server`、:meth:`loop." +"create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" +"建立。" #: ../../library/asyncio-eventloop.rst:1593 msgid "Do not instantiate the :class:`Server` class directly." -msgstr "" +msgstr "請勿直接實例化 :class:`Server` 類別。" #: ../../library/asyncio-eventloop.rst:1597 msgid "" @@ -1992,48 +2360,53 @@ msgid "" "with`` statement, it's guaranteed that the Server object is closed and not " "accepting new connections when the ``async with`` statement is completed::" msgstr "" +"*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" +"完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" #: ../../library/asyncio-eventloop.rst:1610 msgid "Server object is an asynchronous context manager since Python 3.7." -msgstr "" +msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" #: ../../library/asyncio-eventloop.rst:1613 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" +"此類別在 Python 3.9.11、3.10.3 和 3.11 中以 ``asyncio.Server`` 的形式被公開。" #: ../../library/asyncio-eventloop.rst:1618 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." -msgstr "" +msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" #: ../../library/asyncio-eventloop.rst:1621 msgid "" "The sockets that represent existing incoming client connections are left " "open." -msgstr "" +msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" #: ../../library/asyncio-eventloop.rst:1624 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." msgstr "" +"伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" +"躍連線)。" #: ../../library/asyncio-eventloop.rst:1630 msgid "Return the event loop associated with the server object." -msgstr "" +msgstr "回傳與伺服器物件關聯的事件迴圈。" #: ../../library/asyncio-eventloop.rst:1636 msgid "Start accepting connections." -msgstr "" +msgstr "開始接受連線。" #: ../../library/asyncio-eventloop.rst:1638 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." -msgstr "" +msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" #: ../../library/asyncio-eventloop.rst:1641 msgid "" @@ -2043,60 +2416,74 @@ msgid "" "or :meth:`Server.serve_forever` can be used to make the Server start " "accepting connections." msgstr "" +"*start_serving* 僅限關鍵字參數只能在 :meth:`loop.create_server` 和 :meth:" +"`asyncio.start_server` 中使用,允許建立一個最初不接受連線的 Server 物件。在這" +"種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." +"serve_forever` 來使 Server 開始接受連線。" #: ../../library/asyncio-eventloop.rst:1652 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" +"開始接受連線,直到協程被取消。取消 ``serve_forever`` 任務會導致伺服器關閉。" #: ../../library/asyncio-eventloop.rst:1656 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." msgstr "" +"如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " +"``serve_forever`` 任務。" #: ../../library/asyncio-eventloop.rst:1678 msgid "Return ``True`` if the server is accepting new connections." -msgstr "" +msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" #: ../../library/asyncio-eventloop.rst:1684 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." -msgstr "" +msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" #: ../../library/asyncio-eventloop.rst:1689 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" +"伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" #: ../../library/asyncio-eventloop.rst:1692 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." msgstr "" +"在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" +"列。在 3.7 中回傳了該串列的副本。" #: ../../library/asyncio-eventloop.rst:1702 msgid "Event Loop Implementations" -msgstr "" +msgstr "事件迴圈實作" #: ../../library/asyncio-eventloop.rst:1704 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." msgstr "" +"asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" +"`ProactorEventLoop`。" #: ../../library/asyncio-eventloop.rst:1707 msgid "" "By default asyncio is configured to use :class:`SelectorEventLoop` on Unix " "and :class:`ProactorEventLoop` on Windows." msgstr "" +"預設情況下,asyncio 配置為在 Unix 上使用 :class:`SelectorEventLoop`,在 " +"Windows 上使用 :class:`ProactorEventLoop`。" #: ../../library/asyncio-eventloop.rst:1713 msgid "An event loop based on the :mod:`selectors` module." -msgstr "" +msgstr "基於 :mod:`selectors` 模組的事件迴圈。" #: ../../library/asyncio-eventloop.rst:1715 msgid "" @@ -2104,6 +2491,8 @@ msgid "" "also possible to manually configure the exact selector implementation to be " "used::" msgstr "" +"使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" +"作: ::" #: ../../library/asyncio-eventloop.rst:1730 msgid ":ref:`Availability `: Unix, Windows." @@ -2111,7 +2500,7 @@ msgstr ":ref:`適用 `:Unix、Windows。" #: ../../library/asyncio-eventloop.rst:1735 msgid "An event loop for Windows that uses \"I/O Completion Ports\" (IOCP)." -msgstr "" +msgstr "用於 Windows 的事件迴圈,使用\"I/O 完成埠\"(IOCP)。" #: ../../library/asyncio-eventloop.rst:1737 msgid ":ref:`Availability `: Windows." @@ -2122,16 +2511,20 @@ msgid "" "`MSDN documentation on I/O Completion Ports `_." msgstr "" +"`I/O 完成埠(I/O Completion Ports)的 MSDN 文件 `_。" #: ../../library/asyncio-eventloop.rst:1747 msgid "Abstract base class for asyncio-compliant event loops." -msgstr "" +msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" #: ../../library/asyncio-eventloop.rst:1749 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." msgstr "" +":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" +"該定義的所有方法。" #: ../../library/asyncio-eventloop.rst:1755 msgid "Examples" @@ -2144,26 +2537,32 @@ msgid "" "call_soon`. Modern asyncio applications rarely need to be written this way; " "consider using the high-level functions like :func:`asyncio.run`." msgstr "" +"請注意,本節中的所有範例都 **故意** 展示如何使用低階事件迴圈 API,如 :" +"meth:`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少" +"需要這種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" #: ../../library/asyncio-eventloop.rst:1767 msgid "Hello World with call_soon()" -msgstr "" +msgstr "使用 call_soon() 的 Hello World 範例" #: ../../library/asyncio-eventloop.rst:1769 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" msgstr "" +"使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " +"World\"``,然後停止事件迴圈: ::" #: ../../library/asyncio-eventloop.rst:1793 msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" +"使用協程和 :func:`run` 函式建立的類似 :ref:`Hello World ` 範例。" #: ../../library/asyncio-eventloop.rst:1800 msgid "Display the current date with call_later()" -msgstr "" +msgstr "使用 call_later() 顯示目前日期" #: ../../library/asyncio-eventloop.rst:1802 msgid "" @@ -2171,45 +2570,57 @@ msgid "" "callback uses the :meth:`loop.call_later` method to reschedule itself after " "5 seconds, and then stops the event loop::" msgstr "" +"一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " +"秒後重新排程自己,然後停止事件迴圈: ::" #: ../../library/asyncio-eventloop.rst:1830 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." msgstr "" +"使用協程和 :func:`run` 函式建立的類似 :ref:`current date " +"` 範例。" #: ../../library/asyncio-eventloop.rst:1837 msgid "Watch a file descriptor for read events" -msgstr "" +msgstr "監聽檔案描述器以進行讀取事件" #: ../../library/asyncio-eventloop.rst:1839 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" msgstr "" +"使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" +"圈: ::" #: ../../library/asyncio-eventloop.rst:1877 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." msgstr "" +"使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " +"`。" #: ../../library/asyncio-eventloop.rst:1881 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." msgstr "" +"另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " +"`。" #: ../../library/asyncio-eventloop.rst:1889 msgid "Set signal handlers for SIGINT and SIGTERM" -msgstr "" +msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" #: ../../library/asyncio-eventloop.rst:1891 msgid "(This ``signals`` example only works on Unix.)" -msgstr "" +msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" #: ../../library/asyncio-eventloop.rst:1893 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" msgstr "" +"使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" +"data:`SIGTERM` 的處理程式: ::"