Skip to content

Commit 8cf035f

Browse files
larry.liumiguelgrinberg
authored andcommitted
redis pub/sub support set password (#116)
1 parent d0dd3e4 commit 8cf035f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

socketio/asyncio_redis_manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,29 @@ class AsyncRedisManager(AsyncPubSubManager): # pragma: no cover
5353
name = 'aioredis'
5454

5555
def __init__(self, url='redis://localhost:6379/0', channel='socketio',
56-
write_only=False):
56+
write_only=False, password=None):
5757
if aioredis is None:
5858
raise RuntimeError('Redis package is not installed '
5959
'(Run "pip install aioredis" in your '
6060
'virtualenv).')
6161
self.host, self.port, self.db = _parse_redis_url(url)
6262
self.pub = None
6363
self.sub = None
64+
self.password = password
6465
super().__init__(channel=channel, write_only=write_only)
6566

6667
async def _publish(self, data):
6768
if self.pub is None:
6869
self.pub = await aioredis.create_redis((self.host, self.port),
69-
db=self.db)
70+
db=self.db,
71+
password=self.password)
7072
return await self.pub.publish(self.channel, pickle.dumps(data))
7173

7274
async def _listen(self):
7375
if self.sub is None:
7476
self.sub = await aioredis.create_redis((self.host, self.port),
75-
db=self.db)
77+
db=self.db,
78+
password=self.password)
7679
self.ch = (await self.sub.subscribe(self.channel))[0]
7780
while True:
7881
return await self.ch.get()

0 commit comments

Comments
 (0)