Errno 35 in Python's socket.sendall() under OS X
April 21, 2010
A little while ago, on the python-help mailing list, a question came up that took a bit of work to find the answer to. Since that list's archives aren't public and Google doesn't seem to have indexed a page with a good discussion of the issue, I thought I'd post about it here (with the original poster's permission, of course).
The poster was using Python 2.6.2 under Mac OS X 10.6.2.
The poster was using Python's ftplib module to upload certain files and some of them would fail consistently with the same number of bytes transferred and with a traceback that ended with:
File "/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6/ftplib.py",
line 452, in storbinary
conn.sendall(buf)
File "<string>", line 1, in sendall
error: [Errno 35] Resource temporarily unavailable
It's pretty clear from that that the OS was temporarily running out of network buffers. But why doesn't the socket's send() method just block until it completes?
The reason is that a socket timeout had been set. If you set a socket timeout in Python (whether through the socket module or something that uses the socket module), sockets are set to be non-blocking "under the covers". (That's pretty much the only way to implement that feature.) It's a somewhat awkward side-effect of doing that that errors resulting from timeouts don't always look like what they are.