差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
python:socket:send_resource_temporarilty_unvailable_error [2016/09/12 15:36] tony [How to resolve?] |
python:socket:send_resource_temporarilty_unvailable_error [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 88: | 行 88: | ||
- 實驗一與四說明,如果將send分批進行且有緩衝,應能正常傳送資料。 | - 實驗一與四說明,如果將send分批進行且有緩衝,應能正常傳送資料。 | ||
- 並非所有OS有相同結果,可能與python或內核有關。 | - 並非所有OS有相同結果,可能與python或內核有關。 | ||
- | 綜合以上,如果要設定timeout,安全作法應該使用non-blocking IO的存取方式。因此 | + | 綜合以上,如果要設定timeout,安全作法應該使用non-blocking IO的存取方式。因此參考[[https://vaidik.in/blog/understanding-non-blocking-io-with-python-part-1.html|此篇文章]]修改程式碼,針對Resource temporarilty unavaliable錯誤retry: |
<code python> | <code python> | ||
def sendData(sock, data): | def sendData(sock, data): | ||
行 105: | 行 105: | ||
return total_sent | return total_sent | ||
</code> | </code> | ||
+ | 呼叫程式改為: | ||
<code python> | <code python> | ||
data = debugfile.read() | data = debugfile.read() |