Closed gtzilla closed 10 years ago
Please, show me the code for the tredis_client function. I need it to get the full picture of what may happen.
Meanwhile, I recommend to not use a connection pool for Pub/Sub operations. If you need to limit a number of opened connections you may do it using a global or class variable (just increment it in init and decrement in close method).
Consider using a global channel listener as other option, especially if you implement a multiuser/conference chat.
I implemented connection pooling after running redis out of connections, which subsequently led to redis filing its' log file with connection error log events and growing to over 160gbs.
As suggested, i will attempt to remove connection pooling.
see tredis_client definition, below
import tornadoredis
import os
CONNECTION_POOL = tornadoredis.ConnectionPool(max_connections=150,
wait_for_available=True)
def get_redis_url():
return urlparse.urlparse(os.environ.get('REDISTOGO_URL', 'redis://localhost:6379'))
def tredis_client(db_index=None):
# logger.warn("conn pool %s" % CONNECTION_POOL)
if not db_index:
db_index = tornado.options.options.db_index
uri = get_redis_url()
return tornadoredis.Client(
host=uri.hostname,
port=uri.port,
password=uri.password,
connection_pool=CONNECTION_POOL,
selected_db=db_index)
Thank you for the source code. I'll try to reproduce the issue.
Please take a look at new helper classes located in tornadoredis.pubsub module. You may find them useful when implementing Pub/Sub subscriptions in your Tornado application.
Please, advise: do you still need a fix for this issue?
I am attempting to implement a simple chat client with connection pooling. Working from the demo, I have created the following ChatHandler class.
https://gist.github.com/gregory80/300e377b91ceac2a3e04
While attempting to use this class in a basic call, an attribute error is generated (See stack trace below). Its not clear why "self" here is Nonetype, or why it would generate an attribute error for write_message.
This exception manifests itself running tornado under gunicorn, and only after at least one connection has been already opened.