Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork214
feat(howto/sockets.po): 翻譯 When Sockets Die 和 Non-blocking Sockets 區塊#581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
5 commits Select commitHold shift + click to select a range
1e581b1
feat(howto/sockets.po): 翻譯 When Sockets Die 和 Non-blocking Sockets 區塊
weijay0804bda9e39
fix(howto/sockets.po): 根據 review 建議更改翻譯內容
weijay0804fd11423
fix(howto/sockets.po): 修改 rst 語法
weijay0804c3e1a40
Apply suggestions from code review
mattwang449ac3556
fix(howto/sockets.po): 更改專有名詞
weijay0804File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
56 changes: 51 additions & 5 deletionshowto/sockets.po
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,7 +8,7 @@ msgstr "" | ||
"Project-Id-Version: Python 3.11\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2022-06-10 00:16+0000\n" | ||
"PO-Revision-Date: 2023-08-12 15:16+0800\n" | ||
"Last-Translator: Jay <weijay0804@gmail.com>\n" | ||
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" | ||
"tw)\n" | ||
@@ -240,7 +240,7 @@ msgstr "" | ||
msgid "" | ||
"The :mod:`multiprocessing` integrates cross-platform IPC into a higher-level " | ||
"API." | ||
msgstr ":mod:`multiprocessing`將跨平台行程間通訊整合到更高層的 API 中。" | ||
#: ../../howto/sockets.rst:134 | ||
msgid "Using a Socket" | ||
@@ -519,7 +519,7 @@ msgstr "" | ||
#: ../../howto/sockets.rst:302 | ||
msgid "When Sockets Die" | ||
msgstr "Sockets 何時銷毀" | ||
#: ../../howto/sockets.rst:304 | ||
msgid "" | ||
@@ -535,10 +535,17 @@ msgid "" | ||
"automatic recycling of resources. In other words, if you do manage to kill " | ||
"the thread, your whole process is likely to be screwed up." | ||
msgstr "" | ||
"使用阻塞式 socket 最糟糕的地方可能是在另一端突然強制關閉(未執行 ``close``)" | ||
"的情況下會發生什麼?你的 socket 很可能會處於阻塞狀態。TCP 是一種可靠的協議," | ||
"它在放棄連線之前會等待很長很長的時間。如果你正在使用執行緒,整個執行緒基本上" | ||
"已經無法使用。在這方面,你無法做太多事情。只要你不做一些愚蠢的事情,比如在" | ||
"執行阻塞式讀取時持有一個鎖,那麼執行緒並不會消耗太多資源。*不要*\\ 試圖終止" | ||
"執行緒 - 執行緒比行程更有效的部分原因是它們避免了與自動回收資源相關的開銷。換" | ||
"句話說,如果你確實設法終止了執行緒,整個行程可能會出現問題。" | ||
#: ../../howto/sockets.rst:318 | ||
msgid "Non-blocking Sockets" | ||
msgstr "非阻塞的 Sockets" | ||
#: ../../howto/sockets.rst:320 | ||
msgid "" | ||
@@ -547,6 +554,9 @@ msgid "" | ||
"calls, in much the same ways. It's just that, if you do it right, your app " | ||
"will be almost inside-out." | ||
msgstr "" | ||
"如果你已經理解了前面的內容,你已經知道了大部分關於使用 sockets 的機制的所需知" | ||
"識,你仍然會以非常相似的方式使用相同的函式。就這樣而已,如果你做的對,你的程式" | ||
"就會是近乎完美的。" | ||
#: ../../howto/sockets.rst:325 | ||
msgid "" | ||
@@ -557,6 +567,11 @@ msgid "" | ||
"the exact same idea. You do this after creating the socket, but before using " | ||
"it. (Actually, if you're nuts, you can switch back and forth.)" | ||
msgstr "" | ||
"在 Python 中可以使用 ``socket.setblocking(False)`` 來設定為非阻塞。在 C 的作" | ||
"法更為複雜(例如,你需要在 BSD 風格的 ``O_NONBLOCK`` 和幾乎沒有區別的 POSIX 風" | ||
"格的 ``O_NDELAY`` 之間做出選擇,這與 ``TCP_NODELAY`` 完全不同),但基本思想是" | ||
"一樣的,你要在建立 socket 後但在使用它之前執行此操作。(實際上,如果你願意的" | ||
"話,你甚至可以來回切換。)" | ||
rockleona marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
#: ../../howto/sockets.rst:332 | ||
msgid "" | ||
@@ -567,17 +582,24 @@ msgid "" | ||
"will grow large, buggy and suck CPU. So let's skip the brain-dead solutions " | ||
"and do it right." | ||
msgstr "" | ||
"主要的機制差異在於 ``send``、``recv``、``connect`` 和 ``accept`` 可能在沒有執" | ||
"行任何操作的情況下就回傳了。你當然有多種選擇。你可以檢查回傳值和錯誤代碼,但" | ||
"這些操作通常會讓自己抓狂。如果你不相信我,不妨試試看。你的應用程式會變得臃" | ||
"腫、錯誤百出,並且占用 CPU。所以,讓我們跳過無腦的解決方案,使用正確的方式。" | ||
#: ../../howto/sockets.rst:339 | ||
msgid "Use ``select``." | ||
msgstr "使用 ``select``。" | ||
#: ../../howto/sockets.rst:341 | ||
msgid "" | ||
"In C, coding ``select`` is fairly complex. In Python, it's a piece of cake, " | ||
"but it's close enough to the C version that if you understand ``select`` in " | ||
"Python, you'll have little trouble with it in C::" | ||
msgstr "" | ||
"在 C 中,編寫 ``select`` 是非常複雜的,但在 Python 中,這很簡單,並與 C 的版" | ||
"本非常類似,如果你理解了 Python 中的 ``select``,在 C 中處理它時也不會有太大" | ||
"的困難: ::" | ||
#: ../../howto/sockets.rst:352 | ||
msgid "" | ||
@@ -589,13 +611,20 @@ msgid "" | ||
"generally a sensible thing to do - give it a nice long timeout (say a " | ||
"minute) unless you have good reason to do otherwise." | ||
msgstr "" | ||
"你傳遞給 ``select`` 三個列表:第一個列表包含你可能想要嘗試讀取的所有 " | ||
"sockets;第二個包含所有你可能想要嘗試寫入的 sockets,最後一個(通常為空)包含" | ||
"你想要檢查錯誤的 sockets。你應該注意,一個 socket 可以同時存在於多個列表中。" | ||
"``select`` 呼叫是阻塞的,但你可以設置超時。通常這是一個明智的做法 - 除非有" | ||
"充分的理由,否則給它一個很長的超時(比如一分鐘)。" | ||
#: ../../howto/sockets.rst:360 | ||
msgid "" | ||
"In return, you will get three lists. They contain the sockets that are " | ||
"actually readable, writable and in error. Each of these lists is a subset " | ||
"(possibly empty) of the corresponding list you passed in." | ||
msgstr "" | ||
"作為回傳,你將獲得三個列表。它們包含實際上可讀取、可寫入和出錯的 sockets。這" | ||
"些列表中的每一個都是你傳入的相應列表的子集(可能為空)。" | ||
#: ../../howto/sockets.rst:364 | ||
msgid "" | ||
@@ -606,6 +635,11 @@ msgid "" | ||
"nothing. (Actually, any reasonably healthy socket will return as writable - " | ||
"it just means outbound network buffer space is available.)" | ||
msgstr "" | ||
"如果一個 socket 在輸出的可讀列表中,你可以幾乎確定,在這個業務中我們能夠得到" | ||
"的最接近確定的事情是,對該 socket 的 ``recv`` 呼叫將會回傳一些\\ *內容*。對於可寫" | ||
"列表,也是同樣的想法。你將能夠發送一些 *內容*。也許不是全部,但\\ *一些內容*\\ 總比" | ||
"什麼都沒有好。(實際上,任何比較正常的 socket 都會以可寫的方式回傳 - 這只是意味" | ||
"者「外送網路 (outbound network)」的緩衝空間是可用的。)" | ||
#: ../../howto/sockets.rst:371 | ||
msgid "" | ||
@@ -615,6 +649,10 @@ msgid "" | ||
"it in the potential_writers list. If it shows up in the writable list, you " | ||
"have a decent chance that it has connected." | ||
msgstr "" | ||
"如果你有一個「伺服器端」socket,請將其放在 potential_readers 列表中,如果它在" | ||
"可讀列表中出現,你的 ``accept`` 呼叫(幾乎可以確定)會成功。如果你建立了一個" | ||
"新的 socket 去 ``connect`` 到其他地方,請將它放在 potential_writers 列表中," | ||
"如果它在可寫列表中出現,那麼他有可能已經連接上了。" | ||
#: ../../howto/sockets.rst:377 | ||
msgid "" | ||
@@ -624,6 +662,9 @@ msgid "" | ||
"problem of determining whether the other end is done, or just busy with " | ||
"something else." | ||
msgstr "" | ||
"實際上,即使是使用阻塞式 socket 的情況下,``select`` 也很方便。這是一種判斷是否" | ||
"會被阻塞的方法之一 - 當緩衝區中有某些內容時, socket 會回傳為可讀。然而,這" | ||
"仍然無法解決判斷另一端是否完成,或者只是忙於其他事情的問題。" | ||
#: ../../howto/sockets.rst:382 | ||
msgid "" | ||
@@ -633,3 +674,8 @@ msgid "" | ||
"differently on Windows. In fact, on Windows I usually use threads (which " | ||
"work very, very well) with my sockets." | ||
msgstr "" | ||
"**可移植性警告**:在 Unix 上,``select`` 同時適用於 sockets 和文件。但請不要" | ||
"在 Windows 上嘗試這麼做,在 Windows 上,``select`` 只適用於 sockets。同時,請" | ||
"注意,在 C 語言中,許多更進階的 socket 選項在 Windows 上有不同的實現方式。實" | ||
"際上,在 Windows 上,我通常會使用執行緒(這非常,非常有效)與我的 sockets 一起" | ||
"使用。" |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.