Skip to content

Commit e7473b9

Browse files
committed
Hold importer lock
Hold importer lock until the process is shut down, instead of acquiring it over and over again and switching between processes.
1 parent 64dc9e7 commit e7473b9

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

bbblb/services/recording.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,17 @@ async def on_start(self, db: DBContext, locks: LockManager, bbb: BBBHelper):
195195
async def run(self):
196196
try:
197197
while True:
198-
try:
199-
await asyncio.sleep(self.poll_interval)
200-
await self.lock.try_run_locked(self.run_locked)
201-
except asyncio.CancelledError:
202-
raise
203-
except BaseException:
204-
LOG.exception("Unhandled recording import error")
205-
continue
198+
await asyncio.sleep(self.poll_interval + random.random())
199+
await self.lock.try_run_locked(self.run_locked)
206200
finally:
207201
await self.close()
208202

209203
async def run_locked(self):
210-
if self.auto_import:
211-
await self.schedule_waiting()
212-
await self.cleanup()
204+
while await self.lock.check():
205+
if self.auto_import:
206+
await self.schedule_waiting()
207+
await self.cleanup()
208+
await asyncio.sleep(self.poll_interval)
213209

214210
async def schedule_waiting(self):
215211
"""Pick up waiting tasks from inbox"""

0 commit comments

Comments
 (0)