httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damiano Barboni <barb...@meeo.it>
Subject [users@httpd] CLOSE_WAIT management with apche2 and mod_python
Date Thu, 25 Nov 2010 15:33:41 GMT
Hi All,
I’m working with Apache2 and mod_python.

I have a server process that must run a long and heavy data processing.
If the client (the user) decides to stop the data processing, the server
receives the signal and the connection enters in a CLOSE_WAIT status
until the server process has finished. 

Since the resources utilization is high, I would like to manage the
CLOSE_WAIT status and I would like to force the server process to end.
Is there a method to allow the server process to see the connection
status and, in particular, to see if the connection is in CLOSE_WAIT ?

For example, considering the following code:

from mod_python import util
import apache, time, sys

def handler(req):     
    #infinite loop
    while True: 
        time.sleep(2)      
        #open log file
        f = open("/home/damiano/www/test_close_wait.log","a")
        f.write(str(req.connection.aborted))
        f.write("\n")
        f.close()
	
        #exit if connection is in CLOSE_WAIT	
        if req.connection.aborted:
            sys.exit(1)
    
    req.content_type = 'text/html'
    req.write("<p>END</p>")
    
    return apache.OK

The infinite loop can be considered as my data processing. 
req.connection is the connection object associated with the request. 
req.connection.aborted is the element that i have tried to check but,
when the connection changes from ESTABLISHED to CLOSE_WAIT, this
variable does not change and remains to 0 (False).

Does anyone know how to deal with the problem and can help me.

Thanks in advance

Damiano



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message