Permalink
Browse files

made the Http object used so we don't exhaust available ports for soc…

…kets
  • Loading branch information...
1 parent 0b0ab3e commit d96a8f6d9b298ce6c6b4f8cbdde04e9e18acd7c5 Jason Trost committed with Jan 4, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 pysolr.py
View
9 pysolr.py
@@ -297,20 +297,23 @@ def __init__(self, url, decoder=None, timeout=60):
self.path = path.rstrip('/')
self.timeout = timeout
self.log = self._get_log()
-
+ if TIMEOUTS_AVAILABLE:
+ self.http = Http(timeout=self.timeout)
+ else:
+ self.http = None
+
def _get_log(self):
return LOG
def _send_request(self, method, path, body=None, headers=None):
if TIMEOUTS_AVAILABLE:
- http = Http(timeout=self.timeout)
url = self.base_url + path
try:
start_time = time.time()
self.log.debug("Starting request to '%s' (%s) with body '%s'...",
url, method, str(body)[:10])
- headers, response = http.request(url, method=method, body=body, headers=headers)
+ headers, response = self.http.request(url, method=method, body=body, headers=headers)
end_time = time.time()
self.log.info("Finished '%s' (%s) with body '%s' in %0.3f seconds.",
url, method, str(body)[:10], end_time - start_time)

0 comments on commit d96a8f6

Please sign in to comment.