简体   繁体   中英

socket set blocking raising OSError: [Errno 11] Resource temporarily unavailable

I am creating a socket and using it to communicate to python processes.

I create the socket this way because I already have a file descriptor:

sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)

If I receive a lot of requests it will raise a [Errno 11] Resource temporarily unavailable.

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.

Then it looks like it was in nonblocking I/O mode and it was raising EAGAIN error.

So I set it to blocking:

sock.setblocking(1)

But I keep having the same error. Also the socket.fromfd documentation says:

The socket is assumed to be in blocking mode

Firstly, I have no idea what a "python process" is. A process is a process. What language something is written in, or what interpreter may be interpreting something, has nothing to do with anything.

Next, I am not sure what "I create the socket this way because I already have a file descriptor" means. I don't see you creating anything, but, rather, assigning some value from a structure to another variable.

Not knowing how you ORIGINALLY instantiated socket , it is not possible to guess what the resource issue might be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM