[python-win32] ISAPI and threading
Mark Hammond
mhammond at skippinet.com.au
Tue Dec 8 00:35:43 CET 2009
On 8/12/2009 9:45 AM, Preston Landers wrote:
> Someone had mentioned needing to restrict the worker pool to a single
> thread but indicated they didn't know how to do that. I searched
> around MSDN and couldn't find anything relevant. I also checked the
> PyWin32 ISAPI code and didn't see anything that appeared to start a
> new thread. Does anyone know how to force single threading in this
> scenario?
Finding out where the thread was created should be your first goal. You
are correct that pywin32's ISAPI support doesn't create threads except
when establishing that thread-pool - which only happens when you
explicitly sub-class that threaded implementation.
Obviously though, I've no insight into what ISAPI itself does, but it is
reasonable to assume it uses threading to ensure a single ISAPI request
doesn't block the entire server. thread.get_ident() will tell you
indirectly how many threads you are dealing with.
The other option is just to use a lock - create a global lock object and
have every request acquire it and release it when done. You should then
find only 1 thread is ever actually running in your code while the rest
are blocked waiting for the lock. As noted above though, this may
severely impact performance...
HTH,
Mark
More information about the python-win32
mailing list