CINXE.COM

Issue 20611: socket.create_connection() doesn't handle EINTR properly - Python tracker

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> Issue 20611: socket.create_connection() doesn't handle EINTR properly - Python tracker </title> <link rel="shortcut icon" href="@@file/favicon.ico" /> <link rel="stylesheet" type="text/css" href="@@file/main.css" /> <link rel="stylesheet" type="text/css" href="@@file/style.css" /> <link rel="search" type="application/opensearchdescription+xml" href="@@file/osd.xml" title="Python bug tracker search" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script nonce="223e10306491ab13d5953a9c2a34c6914a95eb780eaade79d112347a69cae5ec" type="text/javascript"> submitted = false; function submit_once() { if (submitted) { alert("Your request is being processed.\nPlease be patient."); return false; } submitted = true; return true; } function help_window(helpurl, width, height) { HelpWin = window.open('https://bugs.python.org/' + helpurl, 'RoundupHelpWindow', 'scrollbars=yes,resizable=yes,toolbar=no,height='+height+',width='+width); HelpWin.focus () } </script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.js"></script> <script type="text/javascript" src="@@file/issue.item.js"></script> <link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" /> </head> <body> <!-- Logo --> <h1 id="logoheader"> <a accesskey="1" href="." id="logolink"> <img src="@@file/python-logo.gif" alt="homepage" border="0" id="logo" /></a> </h1> <div id="utility-menu"> <!-- Search Box --> <div id="searchbox"> <form name="searchform" method="get" action="issue" id="searchform"> <div id="search"> <input type="hidden" name="@columns" value="id,github,activity,title,creator,assignee,status,type" /> <input type="hidden" name="@sort" value="-activity" /> <input type="hidden" name="@filter" value="status" /> <input type="hidden" name="@action" value="searchid" /> <input type="hidden" name="ignore" value="file:content" /> <input class="input-text" id="search-text" name="@search_text" size="10" /> <input type="submit" id="submit" value="search" name="submit" class="input-button" /> <input type="radio" name="status" id="status_notresolved" value="-1,1,3" /> <label for="status_notresolved">open</label> <input type="radio" name="status" checked="checked" id="status_all" value="-1,1,2,3" /> <label for="status_all">all</label> </div> </form> </div> </div> <div id="left-hand-navigation"> <!-- Main Menu NEED LEVEL TWO HEADER AND FOOTER --> <div id="menu"> <ul class="level-one"> <li><a href="https://www.python.org/" title="Go to the Python homepage">Python Home</a></li> <li><a href="https://www.python.org/about/" title="About The Python Language">About</a></li> <li><a href="https://www.python.org/blogs/" title="">News</a></li> <li><a href="https://www.python.org/doc/" title="">Documentation</a></li> <li><a href="https://www.python.org/downloads/" title="">Downloads</a></li> <li><a href="https://www.python.org/community/" title="">Community</a></li> <li><a href="https://www.python.org/psf/" title="Python Software Foundation">Foundation</a></li> <li><a href="https://devguide.python.org/" title="Python Developer's Guide">Developer's Guide</a></li> <li class="selected"><a href="." class="selected" title="Python Issue Tracker">Issue Tracker</a> <ul class="level-two"> <li> <strong>Issues</strong> <ul class="level-three"> <li><a href="issue?@template=search&amp;status=1">Search</a></li> <li><a href="issue?@action=random">Random Issue</a></li> <li> <form method="post" action="issue20611"> <input type="submit" class="form-small" value="Show issue:" /> <input class="form-small" size="4" type="text" name="@number" /> <input type="hidden" name="@type" value="issue" /> <input type="hidden" name="@action" value="show" /> </form> </li> </ul> </li> <li> <strong>Summaries</strong> <ul class="level-three"> <li> <a href="issue?status=1&amp;@sort=-activity&amp;@columns=id%2Cgithub%2Cactivity%2Ctitle%2Ccreator%2Cstatus&amp;@dispname=Issues%20with%20patch&amp;@startwith=0&amp;@group=priority&amp;keywords=2&amp;@action=search&amp;@filter=&amp;@pagesize=50">Issues with patch</a> </li> <li> <a href="issue?status=1&amp;@sort=-activity&amp;@columns=id%2Cgithub%2Cactivity%2Ctitle%2Ccreator%2Cstatus&amp;@dispname=Easy%20issues&amp;@startwith=0&amp;@group=priority&amp;keywords=6&amp;@action=search&amp;@filter=&amp;@pagesize=50">Easy issues</a> </li> <li> <a href="issue?@template=stats">Stats</a> </li> </ul> </li> <li> <strong>User</strong> <form method="post" action="issue20611"> <ul class="level-three"> <li> Login<br /> <input size="10" name="openid_identifier" style="" /><br /> <input size="10" type="password" name="__login_password" /><br /> <input type="hidden" name="@action" value="Login" /> <input type="checkbox" name="remember" id="remember" /> <label for="remember">Remember me?</label><br /> <input class="form-small" type="submit" value="Login" /><br /> <input type="hidden" name="__came_from" value="https://bugs.python.org/issue20611?"> <input type="hidden" name="@sort" value=""/> <input type="hidden" name="@group" value=""/> <input type="hidden" name="@pagesize" value="50"/> <input type="hidden" name="@startwith" value="0"/> </li> <li> </li> <li><a href="user?@template=forgotten">Lost&nbsp;your&nbsp;login?</a></li> </ul> </form> </li> <li> <strong>Administration</strong> <ul class="level-three"> <li> <a href="user?@sort=username">User List</a></li> <li> <a href="user?iscommitter=1&amp;@action=search&amp;@sort=username&amp;@pagesize=300">Committer List</a></li> </ul> </li> <li> <strong>Help</strong> <ul class="level-three"> <li><a href="http://docs.python.org/devguide/triaging.html"> Tracker Documentation</a></li> <li><a href="http://wiki.python.org/moin/TrackerDevelopment"> Tracker Development</a></li> <li><a href="https://github.com/python/psf-infra-meta/issues"> Report Tracker Problem</a></li> </ul> </li> </ul> </li> </ul> </div> <!-- menu --> </div> <!-- left-hand-navigation --> <div id="content-body"> <div id="body-main"> <div id="content"> <div id="breadcrumb"> Issue20611 </div> <div id="migration-notice"> <div id="migration-images"> <img width="32" src="@@file/python-logo-small.png" /> ➜ <a href="https://github.com/python/cpython/issues"><img width="32" src="@@file/gh-icon.png" /></a> </div> <p>This issue tracker <b>has been migrated to <a href="https://github.com/python/cpython/issues">GitHub</a></b>, and is currently <b>read-only</b>.<br /> For more information, <a title="GitHub FAQs" href="https://devguide.python.org/gh-faq/"> see the GitHub FAQs in the Python's Developer Guide.</a></p> </div> <div> <form method="post" name="itemSynopsis" onsubmit="return submit_once()" enctype="multipart/form-data" action="issue20611"> <div id="gh-issue-link"> <a href="https://github.com/python/cpython/issues/64810"> <img width="32" src="@@file/gh-icon.png" /> <p> <span>This issue has been migrated to GitHub:</span> https://github.com/python/cpython/issues/64810 </p> </a> </div> <fieldset><legend>classification</legend> <table class="form"> <tr> <th class="required"><a href="http://docs.python.org/devguide/triaging.html#title" target="_blank">Title</a>:</th> <td colspan="3"> <span>socket.create_connection() doesn't handle EINTR properly</span> <input type="hidden" name="title" value="socket.create_connection() doesn't handle EINTR properly"> </td> </tr> <tr> <th class="required"><a href="http://docs.python.org/devguide/triaging.html#type" target="_blank">Type</a>:</th> <td>behavior</td> <th><a href="http://docs.python.org/devguide/triaging.html#stage" target="_blank">Stage</a>:</th> <td>test needed</td> </tr> <tr> <th><a href="http://docs.python.org/devguide/triaging.html#components" target="_blank">Components</a>:</th> <td>IO, Library (Lib)</td> <th><a href="http://docs.python.org/devguide/triaging.html#versions" target="_blank">Versions</a>:</th> <td>Python 3.4, Python 3.5, Python 2.7</td> </tr> </table> </fieldset> <fieldset><legend>process</legend> <table class="form"> <tr> <th><a href="http://docs.python.org/devguide/triaging.html#status" target="_blank">Status</a>:</th> <td>closed</td> <th><a href="http://docs.python.org/devguide/triaging.html#resolution" target="_blank">Resolution</a>:</th> <td>duplicate</td> </tr> <tr> <th> <a href="http://docs.python.org/devguide/triaging.html#dependencies" target="_blank">Dependencies</a>: </th> <td> </td> <th><a href="http://docs.python.org/devguide/triaging.html#superseder" target="_blank">Superseder</a>:</th> <td> Fix EINTR Socket Module issues in 2.7 <span> <!-- <br><span i18n:translate="">View</span>: <a tal:repeat="sup context/superseder" tal:content="python:sup['id'] + ', '*(not repeat['sup'].end)" tal:attributes="href string:issue${sup/id}; title sup/title;"></a> --> <br>View: <a href="issue23863" class="closed" title="Fix EINTR Socket Module issues in 2.7">23863</a> </span> </td> </tr> <tr> <th> <a href="http://docs.python.org/devguide/triaging.html#assigned-to" target="_blank">Assigned To</a>: </th> <td> gregory.p.smith </td> <th> <a href="http://docs.python.org/devguide/triaging.html#nosy-list" target="_blank">Nosy List</a><!-- <span tal:condition="context/nosy_count" tal:replace="python: ' (%d)' % context.nosy_count" /> -->: </th> <td> flox, gregory.p.smith, martin.panter, meishao, neologix, pitrou, tholzer, vstinner </td> </tr> <tr> <th> <a href="http://docs.python.org/devguide/triaging.html#priority" target="_blank">Priority</a>: </th> <td>normal</td> <th> <a href="http://docs.python.org/devguide/triaging.html#keywords" target="_blank">Keywords</a>: </th> <td>patch</td> </tr> </table> </fieldset> </form> <p>Created on <strong>2014-02-12 15:13</strong> by <strong>flox</strong>, last changed <strong>2022-04-11 14:57</strong> by <strong>admin</strong>. This issue is now <strong style="color:#00F; background-color:inherit;">closed</strong>.</p> <table class="files"> <tr><th colspan="5" class="header">Files</th></tr> <tr> <th>File name</th> <th>Uploaded</th> <th>Description</th> <th>Edit</th> </tr> <tr> <td> <a href="file35296/httplib_2.6.4_eintr_patch.py">httplib_2.6.4_eintr_patch.py</a> </td> <td> <span>tholzer</span>, <span>2014-05-20 03:12</span> </td> <td>Python 2.6.4 httplib EINTR patch</td> <td> </td> </tr> <tr> <td> <a href="file35297/httplib_2.7.3_eintr_patch.py">httplib_2.7.3_eintr_patch.py</a> </td> <td> <span>tholzer</span>, <span>2014-05-20 03:13</span> </td> <td>Python 2.7.3 httplib EINTR patch</td> <td> </td> </tr> <tr> <td> <a href="file35361/socketmodule_2.7.6_eintr_patch.c">socketmodule_2.7.6_eintr_patch.c</a> </td> <td> <span>tholzer</span>, <span>2014-05-26 03:48</span> </td> <td>Python 2.7.6 socketmodule EINTR patch</td> <td> </td> </tr> <tr> <td> <a href="file35406/socket_2.7.3_eintr_patch.py">socket_2.7.3_eintr_patch.py</a> </td> <td> <span>tholzer</span>, <span>2014-05-29 22:16</span> </td> <td>python 2.7.3 socket.py EINTR patch</td> <td> </td> </tr> <tr> <td> <a href="file35408/socket_2_7_2_patch.py">socket_2_7_2_patch.py</a> </td> <td> <span>meishao</span>, <span>2014-05-30 01:03</span> </td> <td>python 2.7.2 socket.py EINTR patch</td> <td> </td> </tr> <tr> <td> <a href="file35465/issue20611-connect-eintr-gps01.diff">issue20611-connect-eintr-gps01.diff</a> </td> <td> <span>gregory.p.smith</span>, <span>2014-06-03 07:44</span> </td> <td></td> <td> <a href="/review/20611/#ps12036">review</a> </td> </tr> </table> <table class="messages"> <tr><th colspan="4" class="header">Messages (20)</th></tr> <tr> <th> <a href="#msg211095" id="msg211095">msg211095</a> - <a href="msg211095">(view)</a></th> <th>Author: Florent Xicluna (flox) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-02-12 15:13</th> </tr> <tr> <td colspan="4" class="content"> <pre>I had this sporadic traceback in a project: File "test.py", line 62, in &lt;module&gt; result = do_lqs(client, str(dnvn)) File "test.py", line 25, in do_lqs qualif_service_id = client.create('ti.qualif.service', {}) File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 894, in wrapper return self.execute(obj, method, *params, **kwargs) File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 636, in execute res = self._execute(obj, method, *params) File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 361, in &lt;lambda&gt; wrapper = lambda s, *args: s._dispatch(name, args) File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/xmlrpclib.py#L1489">xmlrpclib.py</a>", line 1489, in __request verbose=self.__verbose File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/xmlrpclib.py#L1235">xmlrpclib.py</a>", line 1235, in request self.send_content(h, request_body) File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/xmlrpclib.py#L1349">xmlrpclib.py</a>", line 1349, in send_content connection.endheaders() File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/httplib.py#L908">httplib.py</a>", line 908, in endheaders self._send_output() File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/httplib.py#L780">httplib.py</a>", line 780, in _send_output self.send(msg) File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/httplib.py#L739">httplib.py</a>", line 739, in send self.connect() File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/httplib.py#L1112">httplib.py</a>", line 1112, in connect sock = socket.create_connection((self.host, self.port), self.timeout) File "/usr/lib/python2.6/<a href="https://github.com/python/cpython/blob/2.6/Lib/socket.py#L561">socket.py</a>", line 561, in create_connection raise error, msg socket.error: [Errno 4] Interrupted system call It seems that the EINTR should be caught by the standard library in all cases: <a href="http://bugs.python.org/issue1628205">http://bugs.python.org/issue1628205</a> But it's not the case for the "socket.create_connection" method (verified in 3.3 and 2.7 source code).</pre> </td> </tr> <tr> <th> <a href="#msg211128" id="msg211128">msg211128</a> - <a href="msg211128">(view)</a></th> <th>Author: Charles-François Natali (neologix) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-02-13 05:13</th> </tr> <tr> <td colspan="4" class="content"> <pre>&gt; It seems that the EINTR should be caught by the standard library in all cases: &gt; <a href="http://bugs.python.org/issue1628205">http://bugs.python.org/issue1628205</a> Yes, it should. &gt; But it's not the case for the "socket.create_connection" method (verified in 3.3 and 2.7 source code). It's not the case for *almost all* syscalls. See <a href="http://bugs.python.org/issue18885">http://bugs.python.org/issue18885</a></pre> </td> </tr> <tr> <th> <a href="#msg218831" id="msg218831">msg218831</a> - <a href="msg218831">(view)</a></th> <th>Author: (tholzer)</th> <th>Date: 2014-05-20 03:12</th> </tr> <tr> <td colspan="4" class="content"> <pre>We encountered the same problem, this is in the context of using PyQt (specifically QProcess) or twisted. They both rely on SIGCHLD for their notification framework. I've attached a httplib EINTR patch for 2.6.4 &amp; 2.7.3.</pre> </td> </tr> <tr> <th> <a href="#msg218833" id="msg218833">msg218833</a> - <a href="msg218833">(view)</a></th> <th>Author: (tholzer)</th> <th>Date: 2014-05-20 04:09</th> </tr> <tr> <td colspan="4" class="content"> <pre>Here is a reproducible test case: import threading import signal import os import httplib def killer(): while 1: os.kill(os.getpid(), signal.SIGINT) def go(): signal.signal(signal.SIGINT, lambda x,y: None) thread = threading.Thread(target=killer) thread.start() while 1: connection = httplib.HTTPConnection("localhost:80") connection.connect() connection.close() if __name__ == '__main__': go() Which gives: Traceback (most recent call last): File "./repro1.py", line 22, in &lt;module&gt; go() File "./repro1.py", line 18, in go connection.connect() File ".../lib/python2.7/<a href="https://github.com/python/cpython/blob/2.7/Lib/httplib.py#L757">httplib.py</a>", line 757, in connect self.timeout, self.source_address) File ".../lib/python2.7/<a href="https://github.com/python/cpython/blob/2.7/Lib/socket.py#L571">socket.py</a>", line 571, in create_connection raise err socket.error:</pre> </td> </tr> <tr> <th> <a href="#msg218836" id="msg218836">msg218836</a> - <a href="msg218836">(view)</a></th> <th>Author: Charles-François Natali (neologix) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-05-20 05:41</th> </tr> <tr> <td colspan="4" class="content"> <pre>As said in a previous comment, we don't want to have EINTR handling code everywhere. The right way to do this is to handle it at the syscall level.</pre> </td> </tr> <tr> <th> <a href="#msg218841" id="msg218841">msg218841</a> - <a href="msg218841">(view)</a></th> <th>Author: Antoine Pitrou (pitrou) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-05-20 11:39</th> </tr> <tr> <td colspan="4" class="content"> <pre>@tholzer, to clarify Charles-François's comment: EINTR should be handled in socket.connect() and socket.getaddrinfo() (the two syscalls called by create_connection(), AFAIR).</pre> </td> </tr> <tr> <th> <a href="#msg219121" id="msg219121">msg219121</a> - <a href="msg219121">(view)</a></th> <th>Author: (tholzer)</th> <th>Date: 2014-05-26 02:58</th> </tr> <tr> <td colspan="4" class="content"> <pre>No problem, I've attached a patch for socket.py for Python 2.7.3. A few notes: getaddrinfo (and gethostbyname, etc.) are already immune to this bug, so I've just fixed the connect() call. The socket does need to be closed after EINTR, otherwise a EINPROGRESS might get returned on subsequent connect() calls.</pre> </td> </tr> <tr> <th> <a href="#msg219122" id="msg219122">msg219122</a> - <a href="msg219122">(view)</a></th> <th>Author: (tholzer)</th> <th>Date: 2014-05-26 03:42</th> </tr> <tr> <td colspan="4" class="content"> <pre>I've also attached a potential patch for the C module <a href="https://github.com/python/cpython/blob/master/Modules/socketmodule.c">Modules/socketmodule.c</a> inside internal_connect(). A few notes: This seems to work both without time-out and with time-out sockets (non-blocking). One concern would be a signal storm prolonging the operation beyond the time-out. Should we keep track of the actual time taken in this loop and check it against the 'timeout' parameter ? Also, I don't think we can call PyErr_CheckSignals() in this context. Does this need to happen at all ?</pre> </td> </tr> <tr> <th> <a href="#msg219337" id="msg219337">msg219337</a> - <a href="msg219337">(view)</a></th> <th>Author: Syou Ei (meishao) <span title="Contributor form received">*</span></th> <th>Date: 2014-05-29 06:02</th> </tr> <tr> <td colspan="4" class="content"> <pre><a href="http://bugs.python.org/issue21602">http://bugs.python.org/issue21602</a> The smtplib.py also has the same problem. The EINTR cannot be handled properly.</pre> </td> </tr> <tr> <th> <a href="#msg219340" id="msg219340">msg219340</a> - <a href="msg219340">(view)</a></th> <th>Author: Syou Ei (meishao) <span title="Contributor form received">*</span></th> <th>Date: 2014-05-29 08:30</th> </tr> <tr> <td colspan="4" class="content"> <pre>@neologix, May I attach the patch file of smtplib.py for review?</pre> </td> </tr> <tr> <th> <a href="#msg219343" id="msg219343">msg219343</a> - <a href="msg219343">(view)</a></th> <th>Author: Florent Xicluna (flox) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-05-29 09:26</th> </tr> <tr> <td colspan="4" class="content"> <pre>@meishao Previous comments answer your question : <a href="http://bugs.python.org/issue20611#msg218836">http://bugs.python.org/issue20611#msg218836</a> <a href="http://bugs.python.org/issue20611#msg218841">http://bugs.python.org/issue20611#msg218841</a></pre> </td> </tr> <tr> <th> <a href="#msg219344" id="msg219344">msg219344</a> - <a href="msg219344">(view)</a></th> <th>Author: Syou Ei (meishao) <span title="Contributor form received">*</span></th> <th>Date: 2014-05-29 10:18</th> </tr> <tr> <td colspan="4" class="content"> <pre>@flox Thank you for your comment. So we just only modify the socket.py to handle the system level call, is it right? Please let me attach the patch file of socket.py for 2.7.2.</pre> </td> </tr> <tr> <th> <a href="#msg219371" id="msg219371">msg219371</a> - <a href="msg219371">(view)</a></th> <th>Author: (tholzer)</th> <th>Date: 2014-05-29 22:16</th> </tr> <tr> <td colspan="4" class="content"> <pre>Oops, I missed a break statement at the end of socket_2.7.3_eintr_patch.py. I've fixed this now in the attached patch. @meishao Could you please also update your socket_2_7_2_patch.py and add the missing break statement ?</pre> </td> </tr> <tr> <th> <a href="#msg219375" id="msg219375">msg219375</a> - <a href="msg219375">(view)</a></th> <th>Author: Syou Ei (meishao) <span title="Contributor form received">*</span></th> <th>Date: 2014-05-30 01:03</th> </tr> <tr> <td colspan="4" class="content"> <pre>@tholzer I've updated socket_2_7_2_patch.py and added the missing break statement.</pre> </td> </tr> <tr> <th> <a href="#msg219376" id="msg219376">msg219376</a> - <a href="msg219376">(view)</a></th> <th>Author: (tholzer)</th> <th>Date: 2014-05-30 01:37</th> </tr> <tr> <td colspan="4" class="content"> <pre>And a test case for smtplib: import threading import signal import os import smtplib def go(): running = True pid = os.getpid() def killer(): while running: os.kill(pid, signal.SIGINT) signal.signal(signal.SIGINT, lambda x,y: None) thread = threading.Thread(target=killer) thread.start() while 1: try: smtplib.SMTP('localhost') except Exception, ex: running = False raise if __name__ == '__main__': go() Fails with: socket.error: [Errno 4] Interrupted system call</pre> </td> </tr> <tr> <th> <a href="#msg219668" id="msg219668">msg219668</a> - <a href="msg219668">(view)</a></th> <th>Author: Gregory P. Smith (gregory.p.smith) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-06-03 07:44</th> </tr> <tr> <td colspan="4" class="content"> <pre>Something like the patch i'm attaching to socketmodule.c is what I would prefer. I haven't looked at or tried tests for it yet.</pre> </td> </tr> <tr> <th> <a href="#msg223890" id="msg223890">msg223890</a> - <a href="msg223890">(view)</a></th> <th>Author: STINNER Victor (vstinner) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2014-07-24 20:30</th> </tr> <tr> <td colspan="4" class="content"> <pre>The issue is just an example of the main issue <a class="closed" title="[closed] handle EINTR in the stdlib" href="issue18885">#18885</a> which proposes to retry interrupted syscalls. I hesitate to mark it as duplicate, but it contains an interesting patch.</pre> </td> </tr> <tr> <th> <a href="#msg235544" id="msg235544">msg235544</a> - <a href="msg235544">(view)</a></th> <th>Author: Martin Panter (martin.panter) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2015-02-08 03:38</th> </tr> <tr> <td colspan="4" class="content"> <pre>See also <a href="https://www.python.org/dev/peps/pep-0475/">PEP 475</a> and <a class="closed" title="[closed] PEP 475 - EINTR handling" href="issue23285">Issue 23285</a> for the general fix in Python 3</pre> </td> </tr> <tr> <th> <a href="#msg240194" id="msg240194">msg240194</a> - <a href="msg240194">(view)</a></th> <th>Author: STINNER Victor (vstinner) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2015-04-06 23:53</th> </tr> <tr> <td colspan="4" class="content"> <pre>This issue was fixed in Python 3.5 as part of the <a href="https://www.python.org/dev/peps/pep-0475/">PEP 475</a>: see issue <a class="closed" title="[closed] PEP 475: handle EINTR in the socket module (connect)" href="issue23618">#23618</a> which modified socket.socket.connect() to handle EINTR. It's not as simple as retrying connect() in a loop. You must respect the socket timeout (it's better to have a monotonic clock here, it's now always the case in Python 3.5). When connect() returns EINTR, the connection runs asynchronously, you have to call select() to wait until the connection completes or fails. Then you have to call getsockopt() to get the socket error code. In Python 3.5, socket.socket.connect() still raises InterruptedError if the socket is non-blocking: <a href="https://docs.python.org/dev/library/socket.html#socket.socket.connect">https://docs.python.org/dev/library/socket.html#socket.socket.connect</a> <a class="closed" title="[closed] socket.create_connection() doesn't handle EINTR properly" href="issue20611">issue20611</a>-connect-eintr-gps01.diff calls again connect() if connect() failed with EINTR. According to the issue <a class="closed" title="[closed] PEP 475: handle EINTR in the socket module (connect)" href="issue23618">#23618</a>, it might work on some platforms, but it's not portable. For Python 2.7 and 3.4, instead of fixing socket.socket.connect(), which requires complex code, we may only workaround the issue in create_connection(). If connect() raises OSError(EINTR), drop the socket and retry with a fresh connection in a loop until the connection completes or raises a different exception. (And do that for each address.)</pre> </td> </tr> <tr> <th> <a href="#msg240232" id="msg240232">msg240232</a> - <a href="msg240232">(view)</a></th> <th>Author: Gregory P. Smith (gregory.p.smith) <span title="Contributor form received">*</span> <img src="@@file/committer.png" title="Python committer" alt="(Python committer)" /></th> <th>Date: 2015-04-07 22:13</th> </tr> <tr> <td colspan="4" class="content"> <pre>i'm moving this to the more recent issue as i like the patch in that one better.</pre> </td> </tr> </table> <table class="history table table-condensed table-striped"><tr><th colspan="4" class="header"> History </th></tr><tr> <th>Date</th> <th>User</th> <th>Action</th> <th>Args</th> </tr> <tr><td>2022-04-11&nbsp;14:57:58</td><td>admin</td><td>set</td><td>github: 64810</td></tr> <tr><td>2015-04-07&nbsp;22:13:49</td><td>gregory.p.smith</td><td>set</td><td>status: open -> closed<br />resolution: duplicate</td></tr> <tr><td>2015-04-07&nbsp;22:13:36</td><td>gregory.p.smith</td><td>set</td><td>superseder: <a rel="nofollow" href="issue23863">Fix EINTR Socket Module issues in 2.7</a><br />messages: + <a rel="nofollow" href="msg240232">msg240232</a></td></tr> <tr><td>2015-04-06&nbsp;23:53:42</td><td>vstinner</td><td>set</td><td>messages: + <a rel="nofollow" href="msg240194">msg240194</a></td></tr> <tr><td>2015-02-08&nbsp;03:38:18</td><td>martin.panter</td><td>set</td><td>nosy: + <a rel="nofollow" href="user14751">martin.panter</a><br />messages: + <a rel="nofollow" href="msg235544">msg235544</a><br /></td></tr> <tr><td>2014-07-24&nbsp;20:30:58</td><td>vstinner</td><td>set</td><td>messages: + <a rel="nofollow" href="msg223890">msg223890</a></td></tr> <tr><td>2014-06-03&nbsp;07:45:05</td><td>gregory.p.smith</td><td>set</td><td>versions: + Python 3.5, - Python 3.3</td></tr> <tr><td>2014-06-03&nbsp;07:44:56</td><td>gregory.p.smith</td><td>set</td><td>stage: test needed</td></tr> <tr><td>2014-06-03&nbsp;07:44:46</td><td>gregory.p.smith</td><td>set</td><td>files: + <a rel="nofollow" href="file35465">issue20611-connect-eintr-gps01.diff</a><br />assignee: <a rel="nofollow" href="user252">gregory.p.smith</a><br />messages: + <a rel="nofollow" href="msg219668">msg219668</a><br /><br />keywords: + <a rel="nofollow" href="keyword2">patch</a></td></tr> <tr><td>2014-05-30&nbsp;01:37:46</td><td>tholzer</td><td>set</td><td>messages: + <a rel="nofollow" href="msg219376">msg219376</a></td></tr> <tr><td>2014-05-30&nbsp;01:03:16</td><td>meishao</td><td>set</td><td>files: + <a rel="nofollow" href="file35408">socket_2_7_2_patch.py</a><br /><br />messages: + <a rel="nofollow" href="msg219375">msg219375</a></td></tr> <tr><td>2014-05-30&nbsp;01:01:28</td><td>meishao</td><td>set</td><td>files: - <a rel="nofollow" href="file35400">socket_2_7_2_patch.py</a></td></tr> <tr><td>2014-05-29&nbsp;22:16:55</td><td>tholzer</td><td>set</td><td>files: - <a rel="nofollow" href="file35359">socket_2.7.3_eintr_patch.py</a></td></tr> <tr><td>2014-05-29&nbsp;22:16:11</td><td>tholzer</td><td>set</td><td>files: + <a rel="nofollow" href="file35406">socket_2.7.3_eintr_patch.py</a><br /><br />messages: + <a rel="nofollow" href="msg219371">msg219371</a></td></tr> <tr><td>2014-05-29&nbsp;10:18:07</td><td>meishao</td><td>set</td><td>files: + <a rel="nofollow" href="file35400">socket_2_7_2_patch.py</a><br /><br />messages: + <a rel="nofollow" href="msg219344">msg219344</a></td></tr> <tr><td>2014-05-29&nbsp;09:26:53</td><td>flox</td><td>set</td><td>messages: + <a rel="nofollow" href="msg219343">msg219343</a></td></tr> <tr><td>2014-05-29&nbsp;08:30:17</td><td>meishao</td><td>set</td><td>messages: + <a rel="nofollow" href="msg219340">msg219340</a></td></tr> <tr><td>2014-05-29&nbsp;07:43:29</td><td>neologix</td><td>link</td><td><a rel="nofollow" href="issue21602">issue21602 superseder</a></td></tr> <tr><td>2014-05-29&nbsp;06:02:16</td><td>meishao</td><td>set</td><td>nosy: + <a rel="nofollow" href="user19651">meishao</a><br />messages: + <a rel="nofollow" href="msg219337">msg219337</a><br /></td></tr> <tr><td>2014-05-26&nbsp;03:49:15</td><td>tholzer</td><td>set</td><td>files: - <a rel="nofollow" href="file35360">socketmodule_2.7.6_eintr_patch.c</a></td></tr> <tr><td>2014-05-26&nbsp;03:48:52</td><td>tholzer</td><td>set</td><td>files: + <a rel="nofollow" href="file35361">socketmodule_2.7.6_eintr_patch.c</a></td></tr> <tr><td>2014-05-26&nbsp;03:42:02</td><td>tholzer</td><td>set</td><td>files: + <a rel="nofollow" href="file35360">socketmodule_2.7.6_eintr_patch.c</a><br /><br />messages: + <a rel="nofollow" href="msg219122">msg219122</a></td></tr> <tr><td>2014-05-26&nbsp;02:58:56</td><td>tholzer</td><td>set</td><td>files: + <a rel="nofollow" href="file35359">socket_2.7.3_eintr_patch.py</a><br /><br />messages: + <a rel="nofollow" href="msg219121">msg219121</a></td></tr> <tr><td>2014-05-20&nbsp;11:39:48</td><td>pitrou</td><td>set</td><td>messages: + <a rel="nofollow" href="msg218841">msg218841</a></td></tr> <tr><td>2014-05-20&nbsp;05:41:32</td><td>neologix</td><td>set</td><td>messages: + <a rel="nofollow" href="msg218836">msg218836</a></td></tr> <tr><td>2014-05-20&nbsp;04:09:06</td><td>tholzer</td><td>set</td><td>messages: + <a rel="nofollow" href="msg218833">msg218833</a></td></tr> <tr><td>2014-05-20&nbsp;03:13:37</td><td>tholzer</td><td>set</td><td>files: + <a rel="nofollow" href="file35297">httplib_2.7.3_eintr_patch.py</a></td></tr> <tr><td>2014-05-20&nbsp;03:13:01</td><td>tholzer</td><td>set</td><td>files: + <a rel="nofollow" href="file35296">httplib_2.6.4_eintr_patch.py</a><br />nosy: + <a rel="nofollow" href="user11846">tholzer</a><br />messages: + <a rel="nofollow" href="msg218831">msg218831</a><br /><br /></td></tr> <tr><td>2014-02-13&nbsp;05:13:36</td><td>neologix</td><td>set</td><td>messages: + <a rel="nofollow" href="msg211128">msg211128</a></td></tr> <tr><td>2014-02-12&nbsp;15:19:07</td><td>flox</td><td>set</td><td>nosy: + <a rel="nofollow" href="user252">gregory.p.smith</a>, <a rel="nofollow" href="user2040">pitrou</a><br /></td></tr> <tr><td>2014-02-12&nbsp;15:16:07</td><td>vstinner</td><td>set</td><td>nosy: + <a rel="nofollow" href="user2377">vstinner</a>, <a rel="nofollow" href="user12146">neologix</a><br /></td></tr> <tr><td>2014-02-12&nbsp;15:13:52</td><td>flox</td><td>create</td><td></td></tr> </table> </div> </div> <!-- content-body --> <div id="footer"> <div id="credits"> Supported by <a href="https://python.org/psf-landing/" title="The Python Software Foundation">The Python Software Foundation</a>, <br> Powered by <a href="http://roundup.sourceforge.net" title="Powered by the Roundup Issue Tracker">Roundup</a> </div> <!-- credits --> Copyright &copy; 1990-2022, <a href="http://python.org/psf">Python Software Foundation</a><br /> <a href="http://python.org/about/legal">Legal Statements</a> </div> <!-- footer --> </div> <!-- body-main --> </div> <!-- content --> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10