Problem: 'Threads' in Python?

Robert Brewer fumanchu at amor.org
Mon Jan 5 14:59:13 EST 2004


If you use mod_python with Apache, or ASP/IIS, you can spawn a new
thread (see the threading module in the Python Library), and the page
request will complete. Since the python module is not reloaded between
requests, the new thread will continue even after the original thread
has terminated. Not sure if that's worth it to you to change, or if
there's a way to do it with bare cgi.


FuManChu
at amor.org

> -----Original Message-----
> From: Ralph Sluiters [mailto:ralph at sluiters.de] 
> Sent: Monday, January 05, 2004 11:58 AM
> To: python-list at python.org
> Subject: Problem: 'Threads' in Python?
> 
> 
> Hi,
> i've got a small problem with my python-script. It is a 
> cgi-script, which is
> called regulary (e.g. every 5 minutes) and returns a 
> xml-data-structure.
> This script calls a very slow function, with a duration of 
> 10-40 seconds. To
> avoid delays, i inserted a cache for the data. So, if the 
> script is called,
> it returns the last caculated data-structure and then the 
> function is called
> again and the new data is stored in the cache. (There is no 
> problem to use
> older but faster data)
> 
> My problem is, that the client (A Java program (or browser, 
> command line))
> waits, until the whole script has ended and so the cache is 
> worthless. How
> can I tell the client/browser/... that after the last print 
> line there is no
> more data and it can proceed? Or how can I tell the python 
> script, that
> everything after the return of the data (the retieval of the 
> new data and
> the storage in a file) can be done in an other thread or in 
> the background?
> 
> Greetings
> 
> Ralph
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list