On Friday 06 August 2004 21:44, Sebastien Bigaret wrote:
[snip]
First .. i'm very busy w/ computer off, right now so ..
Anyways
Post by Sebastien BigaretI'm not sure this is exact --I've read your post there, and I do not
agree w/ your analysis: I can be wrong of course since my experience w/
mod_python is really thin, but to my understanding there is a global
namespace available w/ mod-python, the global namespace that exists
within the subinterpreter dedicated to an application.
First, i won't talk about apache1 but take care that apache2 isn't really
stable. I use it in production right now but i disabled the thread support.
I get to much trouble w/ it. They is 3 kind of process handling in apache2
fork / thread / mixed (i don't recall it but i hope it's true ..:)
I won't go deeper in explain but cut/paste the answer i got about MPServlet
(which use mod_python + apache2) from Daniel Popowich:
"""
Your questions are related to each other and are frequently asked on
the mod_python discussion list. The problem with maintaining global
data with mod_python (and servlets doesn't solve this issue) is
tightly related to how apache maintains processes and threads. If you
are on linux or other unix-like OS, then apache uses the prefork MPM
by default. This is a multi-process MPM where each request is handled
by a separate process, so you end up with N python interpreters, where
N is the number of processes apache has forked. In such an
environment, the only way to have global data is through some external
storage: sessions, db, shared memory, etc.
For unix, there is the worker MPM which is a hybrid
multi-process/multi-threaded server. With worker you can control
apache such that you have ONE process with multiple threads. I know
one person who is using servlets in such a manner. (This is the
default on windows with the winnt MPM.) In such an environment you
can have global data shared across requests, but of course, you'll
have to wrap your data in mutexes of some sort to avoid threads
stepping on each other.
If the data you want shared across requests is tied to a particular
user, then sessions are an excellent solution. Light-weight and
pretty fast. Servlets has builtin support for sessions; see the api
doc or the tutorial.
"""
In short, using if you're using the fork behaviour, you can't share
data. So in modeling => time consuming import .. and multiple
(with no way to reduce without restart ).. interpreter .. not talking
about the trouble you can get if you have some multiple virtual host
etc etc ..
If you want to share data, you need to use the multi-thread, but
you have to play w/ python thread/mutexes. And everybody around
know I don't want to play w/ thread. In modeling, i don't know if
you can do something like this. I mean, share a 'global' editing
context, and garantues that it's thread safe. (without of course
ending w/ a lock/unlock around each http request). I use SQObject
for a couple of things right now, and I get exactly this kind of
troubles. For example SQLite or MySQL DB Api aren't thread safe.
(I get weird issues about lost connection in MySQL) ..
So that's the dilemma (the post in my blog, is about all kind
of web frameworks, but here is example) If you don't want to
share objects, ok but you will loose time because you can use
some cache behaviours ..
I you want to share, it's ok, but you need to play w/ generator
(àla Twisted) or to play w/ the mutexes. And i didn't find a way to
do it the nice way, because most of python modules doesn't
scale very well in threaded env.
In my point of view, quixote offer a good way to handle this.
Because it use the same prefork / reuse process that apache
does. So you don't have to deal w/ threadObuggy modules, and
you can really handle multiples connections without any other
artifact, and without loosing time in big lock/unlock.
(I know Zope can handle multiple cnx without too much pain
by threading. But Zope's threads aren't really used to do
multiple task at the same time. It's just a way to accept http
request without locking ..)
Post by Sebastien BigaretPost by s***@larsen-b.comLook at http://www.larsen-b.com/Article/130.html for little deeper
explain of the problem.
I haven't do this kind of stuff for a while.. but i think Modeling need
something like Durus do .. a server process.. :)
Interesting indeed, I'll have a look at that. Do you have experience
with this? How do they serialize objects that are transmitted between
the server and its client?
I played w/ it in a recent project, it's more simple than ZODB + ZEO ..
but i don't know how it works.
While finishing this mail, i remember that's a modeling mailing list, and
need to apologize to other that don't want to hear about http handling
Hope this helps. / I know i need to go to english course sooooonnnn :)