我創建一個套接字,並用它來傳達給蟒蛇的過程。插座設置阻斷提高OSERROR:[錯誤11]資源暫時不可用
我創建套接字這種方式,因爲我已經有一個文件描述:
sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
如果我收到了大量請求,這將引發[錯誤11]資源暫時不可用。
When the message does not fit into the send buffer of the socket, send() normally blocks, unless the socket has been placed in nonblocking I/O mode. In nonblocking mode it would fail with the error EAGAIN or EWOULDBLOCK in this case. The select(2) call may be used to determine when it is possible to send more data.
然後它看起來像是處於非阻塞I/O模式,它引發了EAGAIN錯誤。
所以我把它設成阻塞:
sock.setblocking(1)
,但我一直有同樣的錯誤。另外socket.fromfd文檔說:
The socket is assumed to be in blocking mode
當你說「* *它會提高......」你的意思是你得到這個異常從'socket.fromfd'打電話? –
我有過包裹在除OSERROR,E一試插座發送數據的另一種方法:這引起了errno的11 – lapinkoira
據我所知,你應該只得到'EAGAIN'(錯誤11)在'send'呼叫如果(一)該套接字設置爲非阻塞,或(b)有'setsockopt(...,SO_SNDTIMEO,...)設置超時' –