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, haypo, neologix, pitrou, python-dev
Priority: normal Keywords: patch

Created on 2013-11-28 21:10 by haypo, last changed 2013-12-03 23:45 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
socket.patch haypo, 2013-11-28 21:10 review
Messages (3)
msg204698 - (view) Author: STINNER Victor (haypo) * (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) 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
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:42hayposetnosy: + gvanrossum, pitrou, neologix
2013-11-28 21:10:09haypocreate