[Web-SIG] Pre-PEP: Python Web Container Interface v1.0
Phillip J. Eby
pje at telecommunity.com
Tue Dec 9 14:43:59 EST 2003
At 04:54 PM 12/8/03 -0800, Greg Stein wrote:
>I'm not convinced. If an application is designed with a per-process model
>in mind (e.g. CGI), and then you drop it into a threaded model... BOOM!
>The application needs to declare whether it is thread-safe. The container
>can then verify whether that application can be run within the container
>and the container's current configuration.
>For example, if you drop a non-thread-safe app into a threaded mod_python,
>then I would expect an error to be thrown, and the app to *not* be loaded.
>The simple fact is that threading (and the execution model, in general) is
>part of the environment. You can't limit it to just the three streams plus
>some "environ" dictionary. There is a *very* real impact on the
>application, based on how the container is executing those apps.
I'll add a "Threading and Process Issues" section to the PEP, explicitly
addressing the types of issues that could occur (that we know of at
present), and recommending what framework and container authors should
document about their framework or container's requirements or
capabilities. However, I think that trying to establish a metadata
standard for these issues is premature, and should be left to a version
2.0, similar to the way the DBAPI 2.0 added a threading metadata
specification, after driver authors and users had some experience with what
kinds of issues existed.
(Note that although lots of people have so far said "threading is important
and should be in the spec", nobody has said, "this is what the spec should
say about it." I'm taking this as an indication that nobody really knows
what it should say, and that it's therefore premature to specify it.)
Anyway, attempting to summarize the issues raised so far:
* A framework that uses globals for inter-request communication will fail
in a multi-process container
* A framework that uses files or shared memory as an IPC mechanism will
fail in a multi-server cluster container
* Some frameworks are not thread-safe unless multiple application objects
* Some frameworks are not thread-safe *even if* multiple application
objects are created
* Some frameworks may require explicit flagging, or other special coding
practices in order to be thread-safe
Have I missed anything?
More information about the Web-SIG