Gregory P. Smith added the comment:
i'm moving this to the more recent issue as i like the patch in that one better.
--
superseder: - Fix EINTR Socket Module issues in 2.7
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
Changes by Gregory P. Smith g...@krypto.org:
--
resolution: - duplicate
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
STINNER Victor added the comment:
This issue was fixed in Python 3.5 as part of the PEP 475: see issue #23618
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
Martin Panter added the comment:
See also PEP 475 and Issue 23285 for the general fix in Python 3
--
nosy: +vadmium
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
STINNER Victor added the comment:
The issue is just an example of the main issue #18885 which proposes to retry
interrupted syscalls. I hesitate to mark it as duplicate, but it contains an
interesting patch.
--
___
Python tracker
Gregory P. Smith added the comment:
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.
--
assignee: - gregory.p.smith
keywords: +patch
Added file:
Changes by Gregory P. Smith g...@krypto.org:
--
versions: +Python 3.5 -Python 3.3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
___
Changes by Gregory P. Smith g...@krypto.org:
--
stage: - test needed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
___
Python-bugs-list
Syou Ei added the comment:
http://bugs.python.org/issue21602
The smtplib.py also has the same problem.
The EINTR cannot be handled properly.
--
nosy: +meishao
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
Syou Ei added the comment:
@neologix,
May I attach the patch file of smtplib.py for review?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
Florent Xicluna added the comment:
@meishao
Previous comments answer your question :
http://bugs.python.org/issue20611#msg218836
http://bugs.python.org/issue20611#msg218841
--
___
Python tracker rep...@bugs.python.org
Syou Ei added the comment:
@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.
--
Added file: http://bugs.python.org/file35400/socket_2_7_2_patch.py
tholzer added the comment:
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 ?
--
Added file:
Changes by tholzer thol...@wetafx.co.nz:
Removed file: http://bugs.python.org/file35359/socket_2.7.3_eintr_patch.py
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
Changes by Syou Ei oss.sh...@gmail.com:
Removed file: http://bugs.python.org/file35400/socket_2_7_2_patch.py
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
Syou Ei added the comment:
@tholzer
I've updated socket_2_7_2_patch.py and added the missing break statement.
--
Added file: http://bugs.python.org/file35408/socket_2_7_2_patch.py
___
Python tracker rep...@bugs.python.org
tholzer added the comment:
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:
tholzer added the comment:
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
tholzer added the comment:
I've also attached a potential patch for the C module Modules/socketmodule.c
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
Changes by tholzer thol...@wetafx.co.nz:
Added file: http://bugs.python.org/file35361/socketmodule_2.7.6_eintr_patch.c
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
Changes by tholzer thol...@wetafx.co.nz:
Removed file: http://bugs.python.org/file35360/socketmodule_2.7.6_eintr_patch.c
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
Antoine Pitrou added the comment:
@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).
--
___
Python tracker
tholzer added the comment:
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 2.7.3.
--
nosy: +tholzer
Added file:
Changes by tholzer thol...@wetafx.co.nz:
Added file: http://bugs.python.org/file35297/httplib_2.7.3_eintr_patch.py
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
tholzer added the comment:
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)
Charles-François Natali added the comment:
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.
--
___
Python tracker rep...@bugs.python.org
New submission from Florent Xicluna:
I had this sporadic traceback in a project:
File test.py, line 62, in module
result = do_lqs(client, str(dnvn))
File test.py, line 25, in do_lqs
qualif_service_id = client.create('ti.qualif.service', {})
File
Changes by STINNER Victor victor.stin...@gmail.com:
--
nosy: +haypo, neologix
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
___
Changes by Florent Xicluna florent.xicl...@gmail.com:
--
nosy: +gregory.p.smith, pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20611
___
Charles-François Natali added the comment:
It seems that the EINTR should be caught by the standard library in all
cases:
http://bugs.python.org/issue1628205
Yes, it should.
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
30 matches
Mail list logo