From 441e78a4730de75886f19820ad19d55b644d65c3 Mon Sep 17 00:00:00 2001 From: asimaranov Date: Thu, 16 Dec 2021 20:01:28 +0300 Subject: [PATCH] Fixed unused import --- aiogram/dispatcher/fsm/storage/mongo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aiogram/dispatcher/fsm/storage/mongo.py b/aiogram/dispatcher/fsm/storage/mongo.py index 25d5a0da..dd2bc60a 100644 --- a/aiogram/dispatcher/fsm/storage/mongo.py +++ b/aiogram/dispatcher/fsm/storage/mongo.py @@ -1,8 +1,8 @@ +import asyncio from contextlib import asynccontextmanager from typing import Any, AsyncGenerator, Dict, Optional try: - import motor from motor.motor_asyncio import AsyncIOMotorClient except ModuleNotFoundError as e: import warnings @@ -42,6 +42,7 @@ class MongoStorage(BaseStorage): self._db = mongo.get_database(db_name) self._with_bot_id = with_bot_id self._with_destiny = with_destiny + self._lock = asyncio.Lock() @classmethod def from_url( @@ -95,7 +96,8 @@ class MongoStorage(BaseStorage): bot: Bot, key: StorageKey, ) -> AsyncGenerator[None, None]: - yield None + async with self._lock: + yield None async def set_state( self,