[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/tests - testHTTPServer.py:1.1.2.4
Shane Hathaway
shane@digicool.com
Wed, 28 Nov 2001 10:29:12 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server/tests
In directory cvs.zope.org:/tmp/cvs-serv9851/tests
Modified Files:
Tag: Zope-3x-branch
testHTTPServer.py
Log Message:
Added some documentation and a test (and fix) for a potential threading bug.
=== Zope3/lib/python/Zope/Server/tests/testHTTPServer.py 1.1.2.3 => 1.1.2.4 ===
from Zope.Server.dual_mode_channel import pull_trigger
from Zope.Server.Adjustments import Adjustments
-
+from Zope.Server.ITask import ITask
from httplib import HTTPConnection
@@ -59,6 +59,20 @@
channel_class = EchoHTTPChannel
+class SleepingTask:
+
+ __implements__ = ITask
+
+ def service(self):
+ sleep(0.2)
+
+ def cancel(self):
+ pass
+
+ def defer(self):
+ pass
+
+
class Tests(unittest.TestCase):
@@ -158,7 +172,17 @@
responses.append(response)
for response in responses:
response.read()
-
+
+ def testThreading(self):
+ # Ensures the correct number of threads keep running.
+ for n in range(4):
+ tasks.addTask(SleepingTask())
+ # Try to confuse the task manager.
+ tasks.setThreadCount(2)
+ tasks.setThreadCount(1)
+ sleep(0.5)
+ # There should be 1 still running.
+ self.failUnlessEqual(len(tasks.threads), 1)
def test_suite():