0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

Python CLI Package: Locking BIRD object

This commit is contained in:
Maria Matejka 2023-05-23 13:43:31 +02:00
parent 545d9b823b
commit 30dc8824ec

View 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