diff --git a/betty/app/__init__.py b/betty/app/__init__.py index e5006e8fe..3dfdf9dc0 100644 --- a/betty/app/__init__.py +++ b/betty/app/__init__.py @@ -347,7 +347,7 @@ def concurrency(self) -> int: with suppress(KeyError): return int(stdos.environ['BETTY_CONCURRENCY']) # Assume that any machine that runs Betty has at least two CPU cores. - return stdos.cpu_count() or 2 + return (stdos.cpu_count() or 2) * 4 @property def async_concurrency(self) -> int: diff --git a/betty/task.py b/betty/task.py index df5665245..bf1d4bc03 100644 --- a/betty/task.py +++ b/betty/task.py @@ -11,11 +11,11 @@ class Context: def __init__(self): self._claims_lock = threading.Lock() - self._claimed_task_ids: MutableSequence[str] = [] + self._claimed_task_ids: set[str] = set() def claim(self, task_id: str) -> bool: with self._claims_lock: if task_id in self._claimed_task_ids: return False - self._claimed_task_ids.append(task_id) - return True + self._claimed_task_ids.add(task_id) + return True