Commit 442866bc authored by Kirill Smelkov's avatar Kirill Smelkov

slapos/recipe/redis/promise: Don't create connection pool explicitly

Because redis.Redis(...) ctor creates connection pool on initialization
and we can rely on it.

Another reason: Redis ctor (in form of StrictRedis.__init__()) has logic
how to process arguments and does selecting - either it is TCP (`host` and
`port` args), or UNIX socket (`unix_socket_path` arg):

    https://lab.nexedi.com/nexedi/slapos/blob/95dbb5b2/slapos/recipe/redis/MyRedis2410.py#L560

Since we are going to introduce unix socket support to redis recipe in
the next patch, and don't want to duplicate StrictRedis.__init__() logic
in promise code, let's refactor promise to delegate argument processing
logic to Redis.

/reviewed-by @kazuhiko  (on !27)
/cc @alain.takoudjou
parent 9b3cfff4
......@@ -8,10 +8,9 @@ def main(args):
host = args['host']
port = int(args['port'])
try:
pool = redis.ConnectionPool(host=host, port=port, db=0)
r = redis.Redis(connection_pool=pool)
r = redis.Redis(host=host, port=port, db=0)
r.publish("Promise-Service","SlapOS Promise")
pool.disconnect()
r.connection_pool.disconnect()
sys.exit(0)
except Exception, e:
print str(e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment