mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
FSM storage closing now is async
This commit is contained in:
parent
84c8548ceb
commit
17871155ee
4 changed files with 4 additions and 4 deletions
|
|
@ -13,7 +13,7 @@ class MemoryStorage(BaseStorage):
|
||||||
async def wait_closed(self):
|
async def wait_closed(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def close(self):
|
async def close(self):
|
||||||
self.data.clear()
|
self.data.clear()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class RedisStorage(BaseStorage):
|
||||||
self._redis: aioredis.RedisConnection = None
|
self._redis: aioredis.RedisConnection = None
|
||||||
self._connection_lock = asyncio.Lock(loop=self._loop)
|
self._connection_lock = asyncio.Lock(loop=self._loop)
|
||||||
|
|
||||||
def close(self):
|
async def close(self):
|
||||||
if self._redis and not self._redis.closed:
|
if self._redis and not self._redis.closed:
|
||||||
self._redis.close()
|
self._redis.close()
|
||||||
del self._redis
|
del self._redis
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class BaseStorage:
|
||||||
In states-storage you can save current user state and data for all steps
|
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.
|
Need override this method and use when application is shutdowns.
|
||||||
You can save data or etc.
|
You can save data or etc.
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ async def on_shutdown(app):
|
||||||
await bot.delete_webhook()
|
await bot.delete_webhook()
|
||||||
|
|
||||||
# Close Redis connection.
|
# Close Redis connection.
|
||||||
dp.storage.close()
|
await dp.storage.close()
|
||||||
await dp.storage.wait_closed()
|
await dp.storage.wait_closed()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue