On 3 September 2010 15:50, Reinout van Rees <[email protected]> wrote: > On 09/03/2010 02:43 AM, Graham Dumpleton wrote: >> >> On Windows you are limited to what you can do with the Apache MPM >> settings. Threads is controlled by ThreadsPerChild. See: >> >> http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadsperchild > > So that also means that you can only restrict the amount of total threads. > There is no way to restrict the number of wsgi threads separately. Nature > of apache on windows, I presume. > > So single-threaded on windows means having just a single thread in a single > process... > > Alas, it is as I feared :-)
Yep. In embedded mode, mod_wsgi is using the same thread pool as is used to handle static file requests by Apache. Unfortunately you can't just have a mutex lock around calling WSGI application, because it could return a generator which is going to be called into after application returns. You could get tricky and acquire the lock and wrap the returned iterable in an object with a close() method to release the lock, using methods as described in: http://www.youtube.com/watch?v=Ouof1OzhL8k&feature=player_embedded but this will prevent wsgi.file_wrapper from being able to use optimised methods for returning files. If this is going an adhoc method to get around a problem, that may though be acceptable. FWIW, I have contemplated in the path having a directive in mod_wsgi whereby you could say: <Location /some/sub/url> WSGIRestrictRequests 1 </Location> with mod_wsgi creating a mutex itself associated with that context and mod_wsgi itself restricting number of concurrent requests that could then enter the code. My thinking on this is where you have specific URLs which have large transient memory requirements. The last thing you want is multiple requests hitting the same code because you could unexpectedly blow out your memory usage. Never did anything about it as couldn't really get anyone to see this as a major problem. Frankly, there are probably various sites out there on memory constrained system which you could hit certain URLs all at the same time and cause huge problems by causing their memory to be all used up. :-) Graham -- You received this message because you are subscribed to the Google Groups "modwsgi" 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/modwsgi?hl=en.
