This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socket.settimeout working incorrectly for connect() method of AF_UNIX socket
Type: Stage:
Components: Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Slon, benjamin.peterson
Priority: normal Keywords:

Created on 2018-08-22 21:04 by Slon, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
bug.py Slon, 2018-08-22 21:04
Messages (3)
msg323910 - (view) Author: Fedor Korotkiy (Slon) Date: 2018-08-22 21:04
Attached program creates listening server socket, fills backlog queue with 2 client socket and performs third connect attempt after setting socket timeout to 5 second.

I expect third connect() attempt to fail after specified timeout of 5 second. That is indeed what's happening for tcp socket (AF_INET).

But when underlying socket has type AF_UNIX, connect() fails immediately with 'Resource temporarily unavailable' error. I'm able to reproduce this issue on linux 4.17.12 and python 3.6.6.

The underlying issue seems to be different behavior of connect(3) system call for unix sockets. Instead of starting operation and returning EINPROGRESS error it fails immediately with EAGAIN error.

Thanks to Vladislav Bidzilya for discovering this issue.
msg323923 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-08-23 04:34
I think what you want to do is not use the timeout feature of Python sockets and instead use mysock.setsockopt(SO_SNDTIMEO, 5).
msg323933 - (view) Author: Fedor Korotkiy (Slon) Date: 2018-08-23 10:13
Hello Benjamin.

That would be appropriate workaround.

Maybe we should update docs to mention it?
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78647
2018-08-23 10:13:55Slonsetmessages: + msg323933
2018-08-23 04:34:36benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg323923
2018-08-22 21:04:11Sloncreate