@@ -19,11 +19,11 @@ msgstr ""
1919
2020#: ../../library/asyncio-tools.rst:7
2121msgid "Command-line introspection tools"
22- msgstr ""
22+ msgstr "命令列內省工具 "
2323
2424#: ../../library/asyncio-tools.rst:9
2525msgid "**Source code:** :source:`Lib/asyncio/tools.py`"
26- msgstr ""
26+ msgstr "**原始碼:** \\ :source:`Lib/asyncio/tools.py` "
2727
2828#: ../../library/asyncio-tools.rst:13
2929msgid ""
@@ -32,16 +32,21 @@ msgid ""
3232"without modifying it or restarting it. The :mod:`!asyncio.tools` submodule "
3333"implements this interface."
3434msgstr ""
35+ ":mod:`!asyncio` 模組可以透過 ``python -m asyncio`` 作為指令碼叫用,以檢查另一"
36+ "個執行中 Python 行程的任務圖,而不需修改或重新啟動該行程。:mod:`!asyncio."
37+ "tools` 子模組實作了此介面。"
3538
3639#: ../../library/asyncio-tools.rst:18
3740msgid "The following commands inspect the process identified by ``PID``:"
38- msgstr ""
41+ msgstr "以下指令用於檢查以 ``PID`` 識別的行程: "
3942
4043#: ../../library/asyncio-tools.rst:20
4144msgid ""
4245"$ python -m asyncio pstree [--retries N] PID\n"
4346"$ python -m asyncio ps [--retries N] PID"
4447msgstr ""
48+ "$ python -m asyncio pstree [--retries N] PID\n"
49+ "$ python -m asyncio ps [--retries N] PID"
4550
4651#: ../../library/asyncio-tools.rst:25
4752msgid ""
@@ -50,26 +55,30 @@ msgid ""
5055"inspect another process. See the :ref:`permission-requirements <permission-"
5156"requirements>` for details."
5257msgstr ""
58+ "這些指令會讀取目標行程的狀態,而不會在其中執行任何程式碼。它們僅在受支援的平"
59+ "台上可用,且可能需要權限才能檢查其他行程。詳情請參閱\\ :ref:`permission-"
60+ "requirements <permission-requirements>`。"
5361
5462#: ../../library/asyncio-tools.rst:31
5563msgid ":ref:`asyncio-graph`"
56- msgstr ""
64+ msgstr ":ref:`asyncio-graph` "
5765
5866#: ../../library/asyncio-tools.rst:32
5967msgid ""
6068"Programmatic APIs for inspecting the async call graph of a task or future in "
6169"the current process."
62- msgstr ""
70+ msgstr "用於檢查目前行程中某個任務或 future 的非同步呼叫圖的程式化 API。 "
6371
6472#: ../../library/asyncio-tools.rst:35
6573msgid ""
6674"The command examples below use this program, which creates a task hierarchy "
6775"suitable for inspection and prints its process ID:"
6876msgstr ""
77+ "以下指令範例使用這個程式,它會建立一個適合檢查的任務階層,並印出其行程 ID:"
6978
7079#: ../../library/asyncio-tools.rst:38
7180msgid "example.py"
72- msgstr ""
81+ msgstr "example.py "
7382
7483#: ../../library/asyncio-tools.rst:38
7584msgid ""
@@ -99,27 +108,56 @@ msgid ""
99108"\n"
100109"asyncio.run(main())"
101110msgstr ""
111+ "import asyncio\n"
112+ "import os\n"
113+ "\n"
114+ "async def play(track):\n"
115+ " await asyncio.sleep(3600)\n"
116+ " print(f\" 🎵 Finished: {track}\" )\n"
117+ "\n"
118+ "async def album(name, tracks):\n"
119+ " async with asyncio.TaskGroup() as tg:\n"
120+ " for track in tracks:\n"
121+ " tg.create_task(play(track), name=track)\n"
122+ "\n"
123+ "async def main():\n"
124+ " print(f\" PID: {os.getpid()}\" )\n"
125+ " async with asyncio.TaskGroup() as tg:\n"
126+ " tg.create_task(\n"
127+ " album(\" Sundowning\" , [\" TNDNBTG\" , \" Levitate\" ]),\n"
128+ " name=\" Sundowning\" ,\n"
129+ " )\n"
130+ " tg.create_task(\n"
131+ " album(\" TMBTE\" , [\" DYWTYLM\" , \" Aqua Regia\" ]),\n"
132+ " name=\" TMBTE\" ,\n"
133+ " )\n"
134+ "\n"
135+ "asyncio.run(main())"
102136
103137#: ../../library/asyncio-tools.rst:67
104138msgid "Run the program in one terminal and leave it running:"
105- msgstr ""
139+ msgstr "在一個終端機中執行此程式,並讓它持續執行: "
106140
107141#: ../../library/asyncio-tools.rst:69
108142msgid ""
109143"$ python example.py\n"
110144"PID: 12345"
111145msgstr ""
146+ "$ python example.py\n"
147+ "PID: 12345"
112148
113149#: ../../library/asyncio-tools.rst:74
114150msgid ""
115151"Then pass the printed process ID to the commands from another terminal. "
116152"Thread IDs, task IDs, file paths, and line numbers vary between runs and "
117153"source layouts."
118154msgstr ""
155+ "然後在另一個終端機中,將印出的行程 ID 傳給這些指令。執行緒 ID、任務 ID、檔案"
156+ "路徑和行號會因每次執行和原始碼配置的不同而有所差異。"
119157
120158#: ../../library/asyncio-tools.rst:81
121159msgid "Command-line options"
122- msgstr ""
160+ msgstr "命令列選項 "
123161
124162#: ../../library/asyncio-tools.rst:85
125163msgid ""
@@ -129,6 +167,9 @@ msgid ""
129167"task hierarchy is blocked and where in its coroutine stack execution has "
130168"paused:"
131169msgstr ""
170+ "以樹狀結構顯示任務與協程之間的關係。每個任務都會顯示其完整的協程堆疊,並巢狀"
171+ "顯示在正在等待它的任務(如果有的話)之下。此子指令有助於快速找出任務階層中哪"
172+ "個分支被阻塞,以及其協程堆疊中執行暫停的位置:"
132173
133174#: ../../library/asyncio-tools.rst:91
134175msgid ""
@@ -162,13 +203,44 @@ msgid ""
162203" └── play example.py:4\n"
163204" └── sleep Lib/asyncio/tasks.py:702"
164205msgstr ""
206+ "$ python -m asyncio pstree 12345\n"
207+ "└── (T) Task-1\n"
208+ " └── main example.py:12\n"
209+ " └── TaskGroup.__aexit__ Lib/asyncio/taskgroups.py:75\n"
210+ " └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124\n"
211+ " ├── (T) Sundowning\n"
212+ " │ └── album example.py:7\n"
213+ " │ └── TaskGroup.__aexit__ Lib/asyncio/taskgroups."
214+ "py:75\n"
215+ " │ └── TaskGroup._aexit Lib/asyncio/taskgroups."
216+ "py:124\n"
217+ " │ ├── (T) TNDNBTG\n"
218+ " │ │ └── play example.py:4\n"
219+ " │ │ └── sleep Lib/asyncio/tasks.py:702\n"
220+ " │ └── (T) Levitate\n"
221+ " │ └── play example.py:4\n"
222+ " │ └── sleep Lib/asyncio/tasks.py:702\n"
223+ " └── (T) TMBTE\n"
224+ " └── album example.py:7\n"
225+ " └── TaskGroup.__aexit__ Lib/asyncio/taskgroups."
226+ "py:75\n"
227+ " └── TaskGroup._aexit Lib/asyncio/taskgroups."
228+ "py:124\n"
229+ " ├── (T) DYWTYLM\n"
230+ " │ └── play example.py:4\n"
231+ " │ └── sleep Lib/asyncio/tasks.py:702\n"
232+ " └── (T) Aqua Regia\n"
233+ " └── play example.py:4\n"
234+ " └── sleep Lib/asyncio/tasks.py:702"
165235
166236#: ../../library/asyncio-tools.rst:119
167237msgid ""
168238"If the await graph contains a cycle, ``pstree`` reports an error instead of "
169239"printing a tree. A cycle in the await graph is unusual and typically "
170240"indicates a programming error:"
171241msgstr ""
242+ "如果等待圖中包含循環,``pstree`` 會回報錯誤,而不會印出樹狀圖。等待圖中出現循"
243+ "環的情況並不常見,通常代表程式有問題:"
172244
173245#: ../../library/asyncio-tools.rst:123
174246msgid ""
@@ -177,19 +249,26 @@ msgid ""
177249"\n"
178250"cycle: Task-2 → Task-3 → Task-2"
179251msgstr ""
252+ "$ python -m asyncio pstree 12345\n"
253+ "ERROR: await-graph contains cycles - cannot print a tree!\n"
254+ "\n"
255+ "cycle: Task-2 → Task-3 → Task-2"
180256
181257#: ../../library/asyncio-tools.rst:132
182258msgid ""
183259"Display a flat table of all pending tasks in the process *PID*. Each row "
184260"shows the event-loop thread ID, task ID and name, coroutine stack, and the "
185261"awaiting task's stack, name, and ID, if any."
186262msgstr ""
263+ "顯示行程 *PID* 中所有擱置中任務的平面表格。每一列會顯示事件迴圈的執行緒 ID、"
264+ "任務 ID 與名稱、協程堆疊,以及等待該任務的任務之堆疊、名稱與 ID(如果有的"
265+ "話)。"
187266
188267#: ../../library/asyncio-tools.rst:136
189268msgid ""
190269"This subcommand prints all tasks regardless of whether the await graph "
191270"contains cycles:"
192- msgstr ""
271+ msgstr "無論等待圖中是否包含循環,此子指令都會印出所有任務: "
193272
194273#: ../../library/asyncio-tools.rst:139
195274msgid ""
@@ -221,3 +300,30 @@ msgid ""
221300"play TaskGroup._aexit -> TaskGroup."
222301"__aexit__ -> album TMBTE 0x10a439d70"
223302msgstr ""
303+ "$ python -m asyncio ps 12345\n"
304+ "tid task id task name coroutine "
305+ "stack awaiter "
306+ "chain awaiter name awaiter id\n"
307+ "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"
308+ "18445801 0x10a456060 Task-1 TaskGroup._aexit -> "
309+ "TaskGroup.__aexit__ -> "
310+ "main "
311+ "0x0\n"
312+ "18445801 0x10a439f60 Sundowning TaskGroup._aexit -> "
313+ "TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> "
314+ "main Task-1 0x10a456060\n"
315+ "18445801 0x10a439d70 TMBTE TaskGroup._aexit -> "
316+ "TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> "
317+ "main Task-1 0x10a456060\n"
318+ "18445801 0x10a2a3a80 TNDNBTG sleep -> "
319+ "play TaskGroup._aexit -> TaskGroup."
320+ "__aexit__ -> album Sundowning 0x10a439f60\n"
321+ "18445801 0x10a2a38a0 Levitate sleep -> "
322+ "play TaskGroup._aexit -> TaskGroup."
323+ "__aexit__ -> album Sundowning 0x10a439f60\n"
324+ "18445801 0x10a2d7150 DYWTYLM sleep -> "
325+ "play TaskGroup._aexit -> TaskGroup."
326+ "__aexit__ -> album TMBTE 0x10a439d70\n"
327+ "18445801 0x10a6bdaa0 Aqua Regia sleep -> "
328+ "play TaskGroup._aexit -> TaskGroup."
329+ "__aexit__ -> album TMBTE 0x10a439d70"
0 commit comments