Fixed timeout and random problems
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
import random
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from exceptions import TimeoutException
|
from exceptions import TimeoutException
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ class RedisConnection:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
conn = StrictRedis(host=self._config.host, port=self._config.port,
|
conn = StrictRedis(host=self._config.host, port=self._config.port,
|
||||||
db=self._config.db)
|
db=self._config.db,
|
||||||
|
socket_timeout=self._config.timeout)
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
||||||
class RedisDBConfig:
|
class RedisDBConfig:
|
||||||
|
|
||||||
DEFAULT_USER_DB = 5
|
DEFAULT_USER_DB = 5
|
||||||
DEFAULT_TIMEOUT = 2 # seconds
|
DEFAULT_TIMEOUT = 1.5 # seconds
|
||||||
|
|
||||||
def __init__(self, key, db_conn):
|
def __init__(self, key, db_conn):
|
||||||
self._db_conn = db_conn
|
self._db_conn = db_conn
|
||||||
@@ -63,8 +64,9 @@ class RedisDBConfig:
|
|||||||
self._sentinel_id = None
|
self._sentinel_id = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Host: {0}, Port: {1}, Sentinel id: {2}, DB: {3}".format(
|
return "Host: {0}, Port: {1}, Sentinel id: {2}, DB: {3}, " \
|
||||||
self.host, self.port, self.sentinel_id, self.db)
|
"Timeout: {4}".format(self.host, self.port, self.sentinel_id,
|
||||||
|
self.db, self.timeout)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self):
|
def host(self):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.4.0',
|
version='0.4.1',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user