We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to know what's the right way to share the connection.
Create a class and add a classmethod,like this
`class MainHandler(tornado.web.RequestHandler): @classmethod async def redis_connection(cls): if not hasattr(cls, '_redis_connection'): cls._redis_connection = await asyncio_redis.Connection.create('127.0.0.1', 6379) return cls._redis_connection
async def get(self): print('get you!') connection: asyncio_redis.Connection = await MainHandler.redis_connection() # subscriber = await connection.start_subscribe() # await subscriber.subscribe(['chan1']) print(id(connection)) try: hit = await connection.brpop(["zzz"], timeout=60) except asyncio_redis.TimeoutError as _: hit = None finally: connection.close() # hit = await subscriber.next_published() self.write("Hello, World, {}".format(hit))`
I found that the pubsub function wen wrong, two request need two messages be sent to the chan1 to return .
any suggestions?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I want to know what's the right way to share the connection.
Create a class and add a classmethod,like this
`class MainHandler(tornado.web.RequestHandler):
@classmethod
async def redis_connection(cls):
if not hasattr(cls, '_redis_connection'):
cls._redis_connection = await asyncio_redis.Connection.create('127.0.0.1', 6379)
return cls._redis_connection
I found that the pubsub function wen wrong, two request need two messages be sent to the chan1 to return .
any suggestions?
The text was updated successfully, but these errors were encountered: