Browse Source

Use new asyncio support in redis package (Fixes #911)

pull/930/head
Miguel Grinberg 3 years ago
parent
commit
0e7691b776
No known key found for this signature in database GPG Key ID: 36848B262DF5F06C
  1. 10
      src/socketio/asyncio_redis_manager.py

10
src/socketio/asyncio_redis_manager.py

@ -2,9 +2,12 @@ import asyncio
import pickle import pickle
try: try:
import aioredis from redis import asyncio as aioredis
except ImportError: except ImportError:
aioredis = None try:
import aioredis
except ImportError:
aioredis = None
from .asyncio_pubsub_manager import AsyncPubSubManager from .asyncio_pubsub_manager import AsyncPubSubManager
@ -39,8 +42,7 @@ class AsyncRedisManager(AsyncPubSubManager): # pragma: no cover
write_only=False, logger=None, redis_options=None): write_only=False, logger=None, redis_options=None):
if aioredis is None: if aioredis is None:
raise RuntimeError('Redis package is not installed ' raise RuntimeError('Redis package is not installed '
'(Run "pip install aioredis" in your ' '(Run "pip install redis" in your virtualenv).')
'virtualenv).')
if not hasattr(aioredis.Redis, 'from_url'): if not hasattr(aioredis.Redis, 'from_url'):
raise RuntimeError('Version 2 of aioredis package is required.') raise RuntimeError('Version 2 of aioredis package is required.')
self.redis_url = url self.redis_url = url

Loading…
Cancel
Save