-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
42 lines (32 loc) · 1.95 KB
/
Copy pathconfig.py
File metadata and controls
42 lines (32 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Central configuration for the task queue.
All tunables live here so behaviour can be changed without touching
the broker/worker logic itself.
"""
import os
# Where the SQLite database file lives. Using an absolute path anchored
# to the project root keeps behaviour consistent regardless of the
# working directory the process was launched from.
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DB_PATH = os.environ.get("TASKQUEUE_DB_PATH", os.path.join(PROJECT_ROOT, "taskqueue.db"))
# How long a worker sleeps between polling attempts when the queue is empty.
POLL_INTERVAL_SECONDS = float(os.environ.get("TASKQUEUE_POLL_INTERVAL", 0.5))
# How often the recurring-schedule background thread checks for due schedules.
SCHEDULER_POLL_INTERVAL_SECONDS = float(os.environ.get("TASKQUEUE_SCHEDULER_POLL_INTERVAL", 2.0))
# Default retry policy. Individual tasks may override max_retries at submit time.
DEFAULT_MAX_RETRIES = int(os.environ.get("TASKQUEUE_MAX_RETRIES", 3))
BACKOFF_BASE_SECONDS = float(os.environ.get("TASKQUEUE_BACKOFF_BASE", 2.0))
BACKOFF_MAX_SECONDS = float(os.environ.get("TASKQUEUE_BACKOFF_MAX", 300.0))
# SQLite will raise "database is locked" under concurrent writers unless
# given a generous busy timeout; workers run as separate processes so this
# matters a lot here.
SQLITE_BUSY_TIMEOUT_MS = int(os.environ.get("TASKQUEUE_BUSY_TIMEOUT_MS", 10_000))
# How many PENDING candidates dequeue() scans in one go when looking for
# a runnable task. Most will have no dependencies and match instantly;
# this only matters when a batch of chained tasks are queued together.
DEQUEUE_CANDIDATE_BATCH = int(os.environ.get("TASKQUEUE_DEQUEUE_BATCH", 50))
# Default number of worker processes spawned by the manager.
DEFAULT_WORKER_COUNT = int(os.environ.get("TASKQUEUE_WORKER_COUNT", 4))
# Flask dashboard
DASHBOARD_HOST = os.environ.get("TASKQUEUE_DASHBOARD_HOST", "127.0.0.1")
DASHBOARD_PORT = int(os.environ.get("TASKQUEUE_DASHBOARD_PORT", 5000))