diff options
author | Guido van Rossum <guido@python.org> | 2002-06-13 15:07:44 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-06-13 15:07:44 +0000 |
commit | 0cb67fbfc3c6a12a48ce018342ddf7d94084496d (patch) | |
tree | 6208f52c17de4c26a377797a72440434713bca3e /Lib | |
parent | 9d7f4a56656f090a331616a4fde59165e5f343e8 (diff) | |
download | cpython-0cb67fbfc3c6a12a48ce018342ddf7d94084496d.tar.gz |
Major overhaul of timeout sockets:
- setblocking(0) and settimeout(0) are now equivalent, and ditto for
setblocking(1) and settimeout(None).
- Don't raise an exception from internal_select(); let the final call
report the error (this means you will get an EAGAIN error instead of
an ETIMEDOUT error -- I don't care).
- Move the select to inside the Py_{BEGIN,END}_ALLOW_THREADS brackets,
so other theads can run (this was a bug in the original code).
- Redid the retry logic in connect() and connect_ex() to avoid masking
errors. This probably doesn't work for Windows yet; I'll fix that
next. It may also fail on other platforms, depending on what
retrying a connect does; I need help with this.
- Get rid of the retry logic in accept(). I don't think it was needed
at all. But I may be wrong.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_socket.py | 5 | ||||
-rw-r--r-- | Lib/test/test_timeout.py | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index cbe1ec0560..485e038cac 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -51,7 +51,10 @@ class ThreadableTest: self.queue = Queue.Queue(1) # Do some munging to start the client test. - test_method = getattr(self, '_' + self._TestCase__testMethodName) + methodname = self.id() + i = methodname.rfind('.') + methodname = methodname[i+1:] + test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py index 8a84258ede..7c7222290a 100644 --- a/Lib/test/test_timeout.py +++ b/Lib/test/test_timeout.py @@ -59,17 +59,17 @@ class CreationTestCase(unittest.TestCase): self.assertRaises(ValueError, self.sock.settimeout, -1L) self.assertRaises(ValueError, self.sock.settimeout, -1.0) - def testTimeoutThenoBlocking(self): + def testTimeoutThenBlocking(self): "Test settimeout() followed by setblocking()" self.sock.settimeout(10) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(0) - self.assertEqual(self.sock.gettimeout(), None) + self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.settimeout(10) self.sock.setblocking(0) - self.assertEqual(self.sock.gettimeout(), None) + self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) |