diff --git a/qwarc/__init__.py b/qwarc/__init__.py index 67074bb..7023ef4 100644 --- a/qwarc/__init__.py +++ b/qwarc/__init__.py @@ -307,8 +307,8 @@ class QWARC: self._tasks = pending async def _insert_subitems(self, item): - async with self.exclusive_db_lock() as cursor: - if item.childItems: + if item.childItems: + async with self.exclusive_db_lock() as cursor: it = iter(item.childItems) while True: values = [(t, v, STATUS_TODO) for t, v in itertools.islice(it, 100000)]