mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-09 12:48:43 +00:00
Python CLI Package: Locking BIRD object
This commit is contained in:
parent
545d9b823b
commit
30dc8824ec
@ -92,6 +92,7 @@ class CLI:
|
|||||||
self.socket = Socket(name)
|
self.socket = Socket(name)
|
||||||
self.connected = False
|
self.connected = False
|
||||||
self.hello = None
|
self.hello = None
|
||||||
|
self.lock = asyncio.Lock()
|
||||||
|
|
||||||
async def open(self):
|
async def open(self):
|
||||||
if self.hello is not None:
|
if self.hello is not None:
|
||||||
@ -125,8 +126,10 @@ class BIRD:
|
|||||||
raise BIRDException("Tried to enter BIRD context (async with) more than once")
|
raise BIRDException("Tried to enter BIRD context (async with) more than once")
|
||||||
|
|
||||||
self.within = True
|
self.within = True
|
||||||
|
await self.cli.lock.acquire()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
async def __aexit__(self, *args):
|
async def __aexit__(self, *args):
|
||||||
await self.cli.close()
|
await self.cli.close()
|
||||||
|
self.cli.lock.release()
|
||||||
self.within = False
|
self.within = False
|
||||||
|
Loading…
Reference in New Issue
Block a user