Hello,
While updating a small application to a more recent version of Pyramid,
I switched from Paste to Waitress for development. However, it looks
like Waitress cannot process two requests concurrently.
The small application (attached) reproduces this. The 'slow' view calls
'time.sleep(5)'. If a request is made against this view, Waitress will
enqueue other requests but will not _process_ them until the 'slow' view
has returned. The log shows that there are multiple threads that handle
all requests, but they do not appear to run concurrently.
The same application ran with Paste ("WITH_PASTE=1 python
waitress_test.py") does not display the same behaviour: Paste does
respond to other requests while the 'slow' one is being processed.
I wonder if the behaviour I have seen with Waitress is expected. The
"design" chapter in the documentation mentions a "pool of worker
threads" and it seems to imply that if a worker thread is busy, another
worker thread will process concurrent requests (at least that's how I
understand it), which does not seem to be the case. By adding a few
debug statements here and there, I saw that this behaviour is due to
"HTTPChannel.task_lock" being shared between all channels. But perhaps
all this is intended. Or I am missing something.
(I ran this under Python 2.7.2 on OS X 10.4 and a recent Ubuntu.)
Cheers,
--
Damien Baty
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.
import time
from pyramid.config import Configurator
from pyramid.response import Response
def slow(request):
time.sleep(5)
return Response('Ok')
def quick(request):
return Response('Ok')
def make_app():
config = Configurator()
config.add_route('slow', '/slow')
config.add_view(slow, route_name='slow')
config.add_route('quick', '/quick')
config.add_view(quick, route_name='quick')
return config.make_wsgi_app()
if __name__ == '__main__':
import os
if os.environ.get('WITH_PASTE'):
from paste.httpserver import serve
else:
from waitress import serve
serve(make_app(), host='0.0.0.0', port=6543)