Fixed behavior on suspend, thanks to Michael Carter for identifying the problem.
This commit is contained in:
@@ -76,7 +76,7 @@ class Hub(BaseHub):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
presult = self.do_poll(seconds)
|
presult = self.do_poll(seconds)
|
||||||
except select.error, e:
|
except (IOError, select.error), e:
|
||||||
if get_errno(e) == errno.EINTR:
|
if get_errno(e) == errno.EINTR:
|
||||||
return
|
return
|
||||||
raise
|
raise
|
||||||
|
@@ -143,6 +143,42 @@ class TestHubSelection(LimitedTestCase):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TestSuspend(LimitedTestCase):
|
||||||
|
TEST_TIMEOUT=3
|
||||||
|
def test_suspend_doesnt_crash(self):
|
||||||
|
import errno
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
self.tempdir = tempfile.mkdtemp('test_suspend')
|
||||||
|
filename = os.path.join(self.tempdir, 'test_suspend.py')
|
||||||
|
fd = open(filename, "w")
|
||||||
|
fd.write("""import eventlet
|
||||||
|
eventlet.Timeout(0.5)
|
||||||
|
try:
|
||||||
|
eventlet.listen(("127.0.0.1", 0)).accept()
|
||||||
|
except eventlet.Timeout:
|
||||||
|
print "exited correctly"
|
||||||
|
""")
|
||||||
|
fd.close()
|
||||||
|
python_path = os.pathsep.join(sys.path + [self.tempdir])
|
||||||
|
new_env = os.environ.copy()
|
||||||
|
new_env['PYTHONPATH'] = python_path
|
||||||
|
p = subprocess.Popen([sys.executable,
|
||||||
|
os.path.join(self.tempdir, filename)],
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=new_env)
|
||||||
|
eventlet.sleep(0.4) # wait for process to hit accept
|
||||||
|
p.send_signal(signal.SIGSTOP) # suspend and resume to generate EINTR
|
||||||
|
p.send_signal(signal.SIGCONT)
|
||||||
|
output, _ = p.communicate()
|
||||||
|
lines = [l for l in output.split("\n") if l]
|
||||||
|
self.assert_("exited correctly" in lines[-1])
|
||||||
|
shutil.rmtree(self.tempdir)
|
||||||
|
|
||||||
|
|
||||||
class Foo(object):
|
class Foo(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user