summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncore.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2012-03-22 15:17:43 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2012-03-22 15:17:43 (GMT)
commit350c94b90067777457be0d13169e937730d70eb4 (patch)
tree8fde3cd687609358132e8d9af400772b4f3dbd07 /Lib/test/test_asyncore.py
parent9faf5ee7509276eb3aef4463ba778632ef4a5fd4 (diff)
downloadcpython-350c94b90067777457be0d13169e937730d70eb4.zip
cpython-350c94b90067777457be0d13169e937730d70eb4.tar.gz
cpython-350c94b90067777457be0d13169e937730d70eb4.tar.bz2
fix #10340: properly handle EINVAL on OSX and also avoid to call handle_connect() in case of a disconnetected socket which is not meant to connect.
Diffstat (limited to 'Lib/test/test_asyncore.py')
-rw-r--r--Lib/test/test_asyncore.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index 53c49a8..507a8da 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -7,6 +7,7 @@ import sys
import time
import warnings
import errno
+import struct
from test import support
from test.support import TESTFN, run_unittest, unlink
@@ -730,6 +731,21 @@ class BaseTestAPI(unittest.TestCase):
finally:
sock.close()
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ @support.reap_threads
+ def test_quick_connect(self):
+ # see: http://bugs.python.org/issue10340
+ server = TCPServer()
+ t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500))
+ t.start()
+
+ for x in range(20):
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
+ struct.pack('ii', 1, 0))
+ s.connect(server.address)
+ s.close()
+
class TestAPI_UseSelect(BaseTestAPI):
use_poll = False