Skip to content

Commit

Permalink
little bugfix and doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
thefab committed Jun 22, 2015
1 parent 02d8386 commit 87b6143
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
30 changes: 23 additions & 7 deletions tornadis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,27 @@ def discard_reply_cb(reply):


class Client(object):
"""High level object to interact with redis.
Attributes:
autoconnect (boolean): True if the client is in autoconnect mode
(and in autoreconnection mode) (default True).
connection_kwargs: Connection object kwargs
"""
"""High level object to interact with redis."""

def __init__(self, autoconnect=True, **connection_kwargs):
"""Constructor.
Args:
autoconnect (boolean): True if the client is in autoconnect mode
(and in autoreconnection mode) (default True).
**connection_kwargs: Connection object kwargs :
host (string): the host name to connect to.
port (int): the port to connect to.
unix_domain_socket (string): path to a unix socket to connect
to (if set, overrides host/port parameters).
read_page_size (int): page size for reading.
write_page_size (int): page size for writing.
connect_timeout (int): timeout (in seconds) for connecting.
tcp_nodelay (boolean): set TCP_NODELAY on socket.
aggressive_write (boolean): try to minimize write latency over
global throughput (default False).
ioloop (IOLoop): the tornado ioloop to use.
"""
self.connection_kwargs = connection_kwargs
self.autoconnect = autoconnect
self.__connection = None
Expand All @@ -43,6 +55,10 @@ def __init__(self, autoconnect=True, **connection_kwargs):
self._condition = toro.Condition()
self._reply_list = None

@property
def title(self):
return self.__connection._redis_server()

def is_connected(self):
"""Returns True is the client is connected to redis.
Expand Down
25 changes: 13 additions & 12 deletions tornadis/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@


class ClientPool(object):
"""High level object to deal with a pool of redis clients.
Attributes:
max_size (int): max size of the pool (-1 means "no limit").
client_timeout (int): timeout in seconds of a connection released
to the pool (-1 means "no timeout").
autoclose (boolean): automatically disconnect released connections
with lifetime > client_timeout (test made every
client_timeout/10 seconds).
client_kwargs (dict): Client constructor arguments
"""
"""High level object to deal with a pool of redis clients."""

def __init__(self, max_size=-1, client_timeout=-1, autoclose=False,
**client_kwargs):
"""Constructor.
Args:
max_size (int): max size of the pool (-1 means "no limit").
client_timeout (int): timeout in seconds of a connection released
to the pool (-1 means "no timeout").
autoclose (boolean): automatically disconnect released connections
with lifetime > client_timeout (test made every
client_timeout/10 seconds).
client_kwargs (dict): Client constructor arguments.
"""
self.max_size = max_size
self.client_timeout = client_timeout
self.client_kwargs = client_kwargs
Expand Down Expand Up @@ -83,7 +84,7 @@ def get_connected_client(self):
if newly_created:
res = yield client.connect()
if not(res):
LOG.warning("can't connect to %s:%i", client.host, client.port)
LOG.warning("can't connect to %s", client.title)
raise tornado.gen.Return(client)

def get_client_nowait(self):
Expand Down

0 comments on commit 87b6143

Please sign in to comment.