[mod_python] strange behavior of mod-python

François Lepoutre francoislepoutre at compuserve.com
Fri Oct 18 14:55:23 EST 2002

>I will inform you to apache 2...

Thank you

>VI've found your mail of
>that concern this problem. May I try to put "ThreadPerChild" to 1 instead
>2 to 50 ?

>I not clearly understood  the problem to doing that: the pb vanishes... and
>performance as well. (pb?)

Yes exactly!

>otherwise have you some example of code to protect  data under stress? I
>don't have any idea to do so.

I am no expert (IT by experience not education).
But python is so simple. I used the following kind
of code (no guarantee on details but you will
get the idea clear).

# at module level (global)
# add this
import threading
my_data_lock =  threading.RLock()

# every time you update your global variables

global my_data_lock

# update your stuff here
# while other thread wait ....

# release the lock

I am sure you could (and should) do it
in a cleaner object-oriented way.
But that solved the threading issue.

-----Messaggio originale-----
Da: François Lepoutre [mailto:francoislepoutre at compuserve.com]
Inviato: venerdì 18 ottobre 2002 11.37
A: Manera, Villiam
Cc: mod_python at modpython.org
Oggetto: Re: [mod_python] strange behavior of mod-python

>I use a class for handle a pool of connection to the data base that became
>persistent after the first call,
>and all the progrma that need a connection to the db have to pass through
>this class.

Same for me. Most odbc drivers are not fully threadsafe.

>But why only une program fall in this problem?
>In what way may I check if different trading are competing (my application
>doesn't call
>expressly any thread, mod python do it for me? I don't use multiple

It all happens under stress only ...

-on apache linux ... when under stress apache forks as many
interpreters as needed. Each intepreters handle the calls
in an organised queue.

No race conditions here. Simple !

- on apache win32 ... when under strees apache win32 calls
for a nex thread. EACH THREAD may access all
your persistent python objects.

You need to put code to protect your data under stress.

>The way apache works on
>Anyway if this may be one problem I will start today to move from apache
>1.3.26 to apache 2.0.43
>with mod-python beta 3 (different management of threading), in order to
>check this problem.

I am quite new here. not tested the beta.

I have not tested that. No time at the moment.
Could you keep me informed on the all thing.

I have to maintain two version of our code.

One for linux, simple. The other one for nt/2K
that cares for concurrency.

The truth .. ain't log or complex but that's
extra code anyway.

Can i have one version only on apache 2
with both threading and forking activated ?

>I've to stay on nt/2000 because the odbc driver for my database it is not
>available on linux

Using a multiplatform db with support of both
win32 and *nix is great. We use ASA.
Great on win32. Runs on *nix.

>Thanks for your interest

mod_python is a great product.. worth digging thru.
You're welcome.


a win32 geek moving multiplatform
thru python/mod_python

-----Messaggio originale-----
Da: François Lepoutre [mailto:francoislepoutre at compuserve.com]
Inviato: giovedì 17 ottobre 2002 23.26
A: Manera, Villiam
Oggetto: Re: [mod_python] strange behavior of mod-python


I love python and like mod_python a lot...
but have had trouble with the mod_python
programming model on nt/2000 because
of threading.

Do you keep db handle or python shared
data structure persistent in the python

If you do, have you made sure that
distinct thread are competing
for the same resource?

Just my two cents...

-----Original Message-----
From: Manera, Villiam <vmanera at manord.com>
To: 'mod_python at modpython.org' <mod_python at modpython.org>
Date: 17 October 2002 19:13
Subject: [mod_python] strange behavior of mod-python

>I'm currently use mod-python 2.7.6 on apache 1.3.26 - windows 2000 with
>python 2.2
>apache config:
>    ScriptAlias /comm/ "E:/script/cgi/comm/"
>    ScriptAlias /tecnico/ "E:/script/cgi/tecnico/"
><Directory "E:/script/cgi/comm">
>        Order Deny,Allow
>        Deny from all
>        Allow from .....
>       ...
>    AddHandler python-program .py
>    PythonHandler mod_python.publisher
> PythonPath "sys.path+['c:/program
>files/python22/lib/site-packages/mdnlib', 'c:/program
>    PythonDebug on
>    </Directory>
>all work fine, but sometimes (today 4 time) when a url is typed:
>I have this behavior from apache:
>HTTP 404 - File non trovato (not found)
>Internet Explorer
>but the program is still in place, and the only way to force apache to
>the program is restart the apache services,
>or make a copy of comm_ocordiu0 in comm_ocordiu1 and then call this one,
>this is not a real problem in developement web server, but  today it
>happened 4 time, in production is happened 2 time in one month,
>and I become in panic.
>Any advice here would be greatly appreciated.
>Mod_python mailing list
>Mod_python at modpython.org

More information about the Mod_python mailing list