]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Python CLI Package: Locking BIRD object python-cli
authorMaria Matejka <mq@ucw.cz>
Tue, 23 May 2023 11:43:31 +0000 (13:43 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 23 May 2023 12:14:28 +0000 (14:14 +0200)
python/BIRD/__init__.py

index 16b13595fa560ef435b40595776bed2a52f2b75b..9d741782cffd482eba830ce373b21e008a9f3ef4 100644 (file)
@@ -92,6 +92,7 @@ class CLI:
         self.socket = Socket(name)
         self.connected = False
         self.hello = None
+        self.lock = asyncio.Lock()
 
     async def open(self):
         if self.hello is not None:
@@ -125,8 +126,10 @@ class BIRD:
             raise BIRDException("Tried to enter BIRD context (async with) more than once")
 
         self.within = True
+        await self.cli.lock.acquire()
         return self
 
     async def __aexit__(self, *args):
         await self.cli.close()
+        self.cli.lock.release()
         self.within = False