[Zope] Re: threading in zope (ignore previous post)
Daniel Mahler
mahler@cyc.com
Mon, 8 Jul 2002 03:19:52 -0500
I found that the 'sequential' behaviour I was
seeing from my product is an artifact of my browser.
Daniel
Daniel Mahler writes:
>
>
> I am trying to figure out how Zope processes concurrent requests.
> I am running Zope using ZServer
> (without a webserver in front)
>
> My initial investigations suggest contradictory answers:
>
> * ZServer uses medusa,
> which uses asyncore which works by single threaded select multiplexing
>
> * z2.py has::
>
> # The size of the thread pool, if ZODB3 is used.
> NUMBER_OF_THREADS=4
>
> sugesting we are running multi threaded.
>
>
> * the following modification of the Minimal Product How-To,
> suggests that requests are being processed single threaded::
>
> from time import sleep, clock, time
>
> from OFS import SimpleItem
>
> class minimal(SimpleItem.SimpleItem, Thread):
>
> "minimal object"
>
> meta_type = 'minimal'
>
> manage_options = (
> {'label': 'View', 'action': 'index_html'},
> )
>
>
> def __init__(self, id):
> "initialise a new instance of Minimal"
> self.id = id
>
> def index_html(self):
> "used to view content of the object"
> time1 = time()
> sleep(10)
> time2 = time()
> return '<html><body>Hello World<br>%s<br>%s<br></body></html>'%(time1,time2)
>
>
> def manage_addMinimal(self, id, RESPONSE=None):
> "Add a Minimal to a folder."
> self._setObject(id, minimal(id))
> RESPONSE.redirect('index_html')
>
> def manage_addMinimalForm(self):
> "The form used to get the instance' id from the user."
> return """<html>
> <body>
> Please type the id of the minimal instance:<br>
> <form name="form" action="manage_addMinimal"><br>
> <input type="text" name="id"><br>
> <input type="submit" value="add">
> </form>
> </body>
> </html>"""
>
> If I fire several requests to an instance of this class in rapid
> succession, Zope serializes them time1 of the second is after time2
> of the first, time1 of the third is after time2 of the second and
> so on, suggesting that Zope is processing the requests purely
> sequentially.
>
> thanks
> Daniel