我已經搜索並且無法找到答案。我正試圖在兩個unix設備之間打開Pyro連接。我可以使用具有相同URI字符串的Pyro4代理連接4次到設備。在第五個連接上,實例掛在我的get數據函數調用上。它經歷了core.py pyro包並最終等待獲取數據。很偶然,這是第四個之後創建將拋出一個異常ConnectionClosedError看起來像這樣的這些開放連接中的一個:Pyro4在超過4個併發連接後有時會拋出「通過對等方重置連接」(Erno 104)
ConnectionClosedError("receiving: connection lost: "+str(x))
ConnectionClosedError: receiving: connection lost: [Errno 104] Connection reset by peer
如果我還沒有明確,以下是什麼原因導致這個問題: - 在與設備的不同SSH會話中打開4個連接,並運行設置pyro代理的重複測試。 (這些工作很好,完成沒有錯誤) - 打開更多的連接,所有連接都掛在我的電話獲取數據。他們至少掛了5分鐘,有些人很少會提出上述例外。 - 不是所有人都會這樣做。四次運行測試中的一次測試結束後,第五次掛起的測試將完成並完成。其他人將遵循,但一次不超過4人。
最後,下面的代碼(在socketutil.py)是其中的例外是實際發生:
def receiveData(sock, size):
"""Retrieve a given number of bytes from a socket.
It is expected the socket is able to supply that number of bytes.
If it isn't, an exception is raised (you will not get a zero length result
or a result that is smaller than what you asked for). The partial data that
has been received however is stored in the 'partialData' attribute of
the exception object."""
try:
retrydelay=0.0
msglen=0
chunks=[]
if hasattr(socket, "MSG_WAITALL"):
# waitall is very convenient and if a socket error occurs,
# we can assume the receive has failed. No need for a loop,
# unless it is a retryable error.
# Some systems have an erratic MSG_WAITALL and sometimes still return
# less bytes than asked. In that case, we drop down into the normal
# receive loop to finish the task.
while True:
try:
data=sock.recv(size, socket.MSG_WAITALL)
if len(data)==size:
return data
# less data than asked, drop down into normal receive loop to finish
msglen=len(data)
chunks=[data]
break
except socket.timeout:
raise TimeoutError("receiving: timeout")
except socket.error:
x=sys.exc_info()[1]
err=getattr(x, "errno", x.args[0])
if err not in ERRNO_RETRIES:
################HERE:###############
raise ConnectionClosedError("receiving: connection lost: "+str(x))
time.sleep(0.00001+retrydelay) # a slight delay to wait before retrying
retrydelay=__nextRetrydelay(retrydelay)
真的會在這裏得到一些方向。提前致謝!