Commit c8d92a1c authored by Stefan H. Holek's avatar Stefan H. Holek

Protect against setNumberOfThreads disappearing after first use...

parent ae60ba1d
......@@ -13,7 +13,7 @@
"""Parts of ZServer support are in this module so they can
be imported more selectively.
$Id: threadutils.py,v 1.6 2004/08/19 15:31:26 shh42 Exp $
$Id$
"""
from threading import Thread
......@@ -22,6 +22,15 @@ from StringIO import StringIO
dummyLOG = StringIO()
def setNumberOfThreads(number_of_threads):
'''Sets number of ZServer threads.'''
try:
from ZServer.PubCore import setNumberOfThreads
setNumberOfThreads(number_of_threads)
except ImportError:
pass
def zserverRunner(host, port, log=None):
'''Runs an HTTP ZServer on host:port.'''
from ZServer import logger, asyncore
......
......@@ -115,7 +115,7 @@ def startZServer(number_of_threads=1, log=None):
if _Z2HOST is None:
_Z2HOST = '127.0.0.1'
_Z2PORT = random.choice(range(55000, 55500))
from ZServer import setNumberOfThreads
from threadutils import setNumberOfThreads
setNumberOfThreads(number_of_threads)
from threadutils import QuietThread, zserverRunner
t = QuietThread(target=zserverRunner, args=(_Z2HOST, _Z2PORT, log))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment