[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/tests - testHTTPServer.py:1.1.2.3
Shane Hathaway
shane@digicool.com
Tue, 27 Nov 2001 15:06:25 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server/tests
In directory cvs.zope.org:/tmp/cvs-serv11273
Modified Files:
Tag: Zope-3x-branch
testHTTPServer.py
Log Message:
Ensure all sockets get closed properly.
=== Zope3/lib/python/Zope/Server/tests/testHTTPServer.py 1.1.2.2 => 1.1.2.3 ===
from httplib import HTTPConnection
-from time import sleep
+from time import sleep, time
import sys
sys.setcheckinterval(120)
@@ -65,6 +65,7 @@
def setUp(self):
tasks.setThreadCount(4)
# Bind to any port on localhost.
+ self.orig_map_size = len(socket_map)
self.server = EchoHTTPServer(LOCALHOST, 0, tasks=tasks, adj=my_adj)
self.port = self.server.socket.getsockname()[1]
self.run_loop = 1
@@ -75,9 +76,18 @@
def tearDown(self):
self.run_loop = 0
+ self.thread.join()
tasks.shutdown()
self.server.close()
- self.thread.join()
+ # Make sure all sockets get closed by asyncore normally.
+ timeout = time() + 5
+ while 1:
+ if len(socket_map) == self.orig_map_size:
+ # Clean!
+ break
+ if time() >= timeout:
+ self.fail('Not all sockets were closed: %s' % `socket_map`)
+ poll(0.1, socket_map)
def loop(self):
while self.run_loop: