2016-07-06 75 views
0

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

+0

当你说“* *它会提高......”你的意思是你得到这个异常从'socket.fromfd'打电话? –

+0

我有过包裹在除OSERROR,E一试插座发送数据的另一种方法:这引起了errno的11 – lapinkoira

+0

据我所知,你应该只得到'EAGAIN'(错误11)在'send'呼叫如果(一)该套接字设置为非阻塞,或(b)有'setsockopt(...,SO_SNDTIMEO,...)设置超时' –

回答

-3

首先,我不知道“python进程”是什么。过程是一个过程。写什么语言,或者什么样的翻译可能会解释某些东西,与任何东西都没有关系。

接下来,我不知道什么是“我创建套接字这种方式,因为我已经有一个文件描述符”的意思。我没有看到你创造任何东西,而是将结构中的某些值赋给另一个变量。

不知道你最初是如何被实例化插座,则无法猜测的资源问题可能是。

+0

字面上我的问题的第三行是实例化一个套接字: socket.fromfd(fd,family,type [,proto]) https://docs.python.org/2/ library/socket.html#socket.fromfd – lapinkoira

+0

这不是问题的答案。如果您需要澄清,请在评论部分提出您的问题。 –

相关问题