socket set blocking raising OSError: [Errno 11] Resource temporarily unavailable
<p>I am creating a socket and using it to communicate to python processes.</p>

<p>I create the socket this way because I already have a file descriptor:</p>

<pre><code>sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
</code></pre>

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

<blockquote>
  <p>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.</p>
</blockquote>

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

<p>So I set it to blocking:</p>

<pre><code>sock.setblocking(1)
</code></pre>

<p>But I keep having the same error. Also the socket.fromfd documentation says:</p>

<blockquote>
  <p>The socket is assumed to be in blocking mode</p>
</blockquote>