From: Maria Matejka Date: Tue, 23 May 2023 11:43:31 +0000 (+0200) Subject: Python CLI Package: Locking BIRD object X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30dc8824ec26a6a00f805497b93064bd7f3f1750;p=thirdparty%2Fbird.git Python CLI Package: Locking BIRD object --- diff --git a/python/BIRD/__init__.py b/python/BIRD/__init__.py index 16b13595f..9d741782c 100644 --- a/python/BIRD/__init__.py +++ b/python/BIRD/__init__.py @@ -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