views:

90

answers:

1

Python 2.5.2, Apache 2.2, Django 1.0.2 final

My Django app tries to connect to a certain port. When that port is busy, I get the error 10048 "Address already in use" from apache. I know where the error is coming from. How do I catch this apache error?

More info:

error at /report/5/2009/08/01/

(10048, 'Address already in use')

Request Method:     GET
Request URL:    http://192.168.0.21/report/5/2009/08/01/
Exception Type:     error
Exception Value:    

(10048, 'Address already in use')

Exception Location:     C:\Python25\Lib\httplib.py in connect, line 683
Python Executable:  C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe
Python Version:     2.5.2
Python Path:    ['D:\\django\\system', 'C:\\Python25\\lib\\site-packages\\setuptools-0.6c9-py2.5.egg', 'C:\\Python25\\lib\\site-packages\\python_memcached-1.44-py2.5.egg', 'C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs', 'c:\\mapnik_0_6_0\\site-packages', 'C:\\Program Files\\Apache Software Foundation\\Apache2.2', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\Lib', 'C:\\Python25\\DLLs', 'C:\\Python25\\Lib\\lib-tk', 'C:\\Program Files\\Apache Software Foundation\\Apache2.2\\bin', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\PIL', 'C:\\Program Files\\GeoDjango\\Django-1.0.2-final']

Server time: don, 10 Sep 2009 11:20:45 +0200

+1  A: 

If you're calling httplib.connect directly from your code, then the try/except should be around that direct call. Or is the call happening indirectly...? Unfortunately Apache is not giving you a stack trace, so if you're having problems locating exactly what call sequence is involved you could put a broad try/except at the highest level available to you, and save a printout of the traceback so you can identify the call site involved (or, edit your question to show the traceback, and we can help you locate it). See the traceback module in Python's standard library for more on how to format a traceback in an except clause.

Alex Martelli