Skip to content

Commit

Permalink
there is no redis.asyncio.__version__
Browse files Browse the repository at this point in the history
-fixes #2010
  • Loading branch information
engAmirEng committed Jul 9, 2023
1 parent 3960115 commit dd1ec4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion telebot/asyncio_storage/redis_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@


redis_installed = True
aioredis_version = None
try:
import aioredis
aioredis_version = tuple(map(int, aioredis.__version__.split(".")[0]))
except ImportError:
try:
import redis
from redis import asyncio as aioredis
aioredis_version = tuple(map(int, redis.__version__.split(".")[0]))
except ImportError:
redis_installed = False

Expand All @@ -24,7 +28,6 @@ def __init__(self, host='localhost', port=6379, db=0, password=None, prefix='tel
raise ImportError('AioRedis is not installed. Install it via "pip install aioredis"')


aioredis_version = tuple(map(int, aioredis.__version__.split(".")[0]))
if aioredis_version < (2,):
raise ImportError('Invalid aioredis version. Aioredis version should be >= 2.0.0')
self.redis = aioredis.Redis(host=host, port=port, db=db, password=password)
Expand Down

0 comments on commit dd1ec4d

Please sign in to comment.