mod_python and threads

grahamd at dscpl.com.au grahamd at dscpl.com.au
Tue Dec 20 04:28:21 CET 2005


Depends on what you mean exactly.

If one is on Win32 or using worker mode for Apache, the threads are
actually initially created down at the Apache level as part of a common
pool and are not bound to a specific Python interpreter. That is, two
distinct requests in time could make use of the same thread from the
common pool, but may end up calling into the context of two different
distinct Python interpreters if it happened that the URL namespace is
assigned against different interpreter instances.

The data for each Python interpreter is distinct, but if multiple
requests come in at the same time which map to the same Python
interpreter instance, then multiple threads can be operating within the
context of the same Python interpreter instance. If the two threads can
be accessing the same code/data, then you would obviously need to worry
about threading issues such as locking etc.

Anyway, you may have to be clearer about what you want to know. The
following may or may not also help.

  http://www.dscpl.com.au/articles/modpython-004.html

BTW, there are bugs related to threading in mod_python 3.1.4 and
earlier. Better if you can use mod_python 3.2.5b, which gets rid of the
nastier threading issues.

Graham




More information about the Python-list mailing list