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: Optimize socket.settimeout() and socket.setblocking(): avoid syscall
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, neologix, pitrou, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2013-11-28 21:10 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
socket.patch vstinner, 2013-11-28 21:10 review
Messages (3)
msg204698 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-28 21:10
Attached patch avoids a syscall on socket.setblocking() and socket.settimeout() when possible: use ioctl(FIONBIO) when available (not only on VMS), or use fcntl() but only call fcntl() twice if the flags changed.

The fcntl() optimization was suggested by Peter Portante some months ago:
https://mail.python.org/pipermail/python-dev/2013-January/123661.html

See also the rejected issue #19813: "Add a new optional timeout parameter to socket.socket() constructor".
msg205169 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-12-03 22:49
LGTM.  I know I've written similar code in Python. :-)
msg205176 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-12-03 23:45
New changeset 5f0d1aad7322 by Victor Stinner in branch 'default':
Close #19827: On UNIX, setblocking() and settimeout() methods of socket.socket
http://hg.python.org/cpython/rev/5f0d1aad7322
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 64026
2013-12-03 23:45:18python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg205176

resolution: fixed
stage: resolved
2013-12-03 22:49:28gvanrossumsetmessages: + msg205169
2013-12-03 21:16:42vstinnersetnosy: + gvanrossum, pitrou, neologix
2013-11-28 21:10:09vstinnercreate