diff --git a/aiogram/contrib/fsm_storage/memory.py b/aiogram/contrib/fsm_storage/memory.py index 52a6264c..fa993e0e 100644 --- a/aiogram/contrib/fsm_storage/memory.py +++ b/aiogram/contrib/fsm_storage/memory.py @@ -13,7 +13,7 @@ class MemoryStorage(BaseStorage): async def wait_closed(self): pass - def close(self): + async def close(self): self.data.clear() def __init__(self): diff --git a/aiogram/contrib/fsm_storage/redis.py b/aiogram/contrib/fsm_storage/redis.py index 4fb4b897..f6fccdb0 100644 --- a/aiogram/contrib/fsm_storage/redis.py +++ b/aiogram/contrib/fsm_storage/redis.py @@ -43,7 +43,7 @@ class RedisStorage(BaseStorage): self._redis: aioredis.RedisConnection = None self._connection_lock = asyncio.Lock(loop=self._loop) - def close(self): + async def close(self): if self._redis and not self._redis.closed: self._redis.close() del self._redis diff --git a/aiogram/dispatcher/storage.py b/aiogram/dispatcher/storage.py index e6651284..127c3b3e 100644 --- a/aiogram/dispatcher/storage.py +++ b/aiogram/dispatcher/storage.py @@ -6,7 +6,7 @@ class BaseStorage: In states-storage you can save current user state and data for all steps """ - def close(self): + async def close(self): """ Need override this method and use when application is shutdowns. You can save data or etc. diff --git a/examples/webhook_example.py b/examples/webhook_example.py index 03ff11ce..0f5a5e11 100644 --- a/examples/webhook_example.py +++ b/examples/webhook_example.py @@ -143,7 +143,7 @@ async def on_shutdown(app): await bot.delete_webhook() # Close Redis connection. - dp.storage.close() + await dp.storage.close() await dp.storage.wait_closed()