[mod_python] Background threads in mod_python

Christian Gross christianhgross at gmail.com
Mon Jul 31 07:45:54 EDT 2006


Hmm... Are you not then making the argument for fastcgi? As much as I 
would like to create a separate process, I am tempted to believe that 
maybe I should not be using Apache in the first place.

Let me give you a context. I am using Ajax and Web Services to create a 
SOA package. The Web Services are provided by mod_python. If I have to 
delegate to a "web service" I am being redundant, no? In contrast, if I 
were to use ASP.NET, or Java Servlets there can be as many background 
threads as necessary and they will not be shot off.

Getting back to Apache. If I am using a threaded model, and Apache kills 
off a request thread, that should not affect a thread I created in 
Python, right? I can understand if the process is shot off, but threads 
within a process should be independent of each other, no?

Christian

Mike Looijmans wrote:
> A much safer option is to create a separate process for this kind of 
> thing. Using the extremely simple XMLRPC package (built-in in Python) 
> you can do calls into the "worker" process.
>
> Apache will terminate your processes/threads at unexpected moments, 
> since it expects all handlers to be stateless and only act in response 
> to incoming requests. It may work on some configurations, but there's 
> no guarantee that your application will behave the same on other systems.
>
>
> Mike Looijmans
> Philips Natlab / Topic Automation
>
>
> Christian Gross wrote:
>> Hi,
>>
>> I have been using mod_python and am wondering about creating
>> background threads. I can create the background thread, but if the
>> thread requires a longer processing time than the request the
>> background thread is exited.
>>
>> Is it possible to create a background thread and have it execute
>> without being killed?
>>
>> Thanks
>>
>> Christian Gross
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>
>
>



More information about the Mod_python mailing list