Skip to content

Commit

Permalink
do not drop server on status code 500 but only if server is really gone
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Sep 3, 2014
1 parent 2005f19 commit 717b978
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -2,6 +2,9 @@
Changes for crate
=================


- improved server failover

2014/08/26 0.11.1
=================

Expand Down
4 changes: 3 additions & 1 deletion src/crate/client/http.py
Expand Up @@ -19,6 +19,7 @@
# with Crate these terms will supersede the license and you may use the
# software solely pursuant to the terms of the relevant commercial agreement.


import heapq
import json
import logging
Expand Down Expand Up @@ -46,6 +47,7 @@
basestring = str

_HTTP_PAT = pat = re.compile('https?://.+', re.I)
SRV_UNAVAILABLE_STATUSES = set((502, 503, 504, 509))


def super_len(o):
Expand Down Expand Up @@ -288,7 +290,7 @@ def _request(self, method, path, server=None, **kwargs):
self._add_server(redirect_server)
return self._request(
method, path, server=redirect_server, **kwargs)
if not server and (500 <= response.status < 600):
if not server and response.status in SRV_UNAVAILABLE_STATUSES:
with self._lock:
# drop server from active ones
self._drop_server(next_server, response.reason)
Expand Down

0 comments on commit 717b978

Please sign in to comment.