我创建一个套接字,并用它来传达给蟒蛇的过程。插座设置阻断提高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,...)设置超时' –