Add in detection of refused connections to the API.

This commit is contained in:
2010-09-11 19:46:54 +01:00
parent 7c4b185063
commit ebe3b26f8a

View File

@@ -2,6 +2,7 @@ import httplib
import urllib import urllib
import xml import xml
import hashlib import hashlib
import socket
from datetime import datetime, timedelta from datetime import datetime, timedelta
from xml.dom import minidom from xml.dom import minidom
from django.db import models from django.db import models
@@ -47,7 +48,10 @@ class CachedDocumentManager(models.Manager):
method = 'POST' method = 'POST'
headers = {"Content-type": "application/x-www-form-urlencoded"} headers = {"Content-type": "application/x-www-form-urlencoded"}
conn = httplib.HTTPConnection(API_URL) try:
conn = httplib.HTTPConnection(API_URL)
except socket.error:
return None
conn.request(method, url_path, paramstr, headers) conn.request(method, url_path, paramstr, headers)
response = conn.getresponse() response = conn.getresponse()