Commit 7058e12f authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

add support for various Huey backends

parent 5246336b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
__version__ = "0.1.86"
__version__ = "0.1.87"
+11 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ VAR_DIR = os.getenv("JAMA_VAR_DIR") or Path(Path.home(), ".jama")
VAR_DIR = Path(VAR_DIR).resolve()

os.makedirs(VAR_DIR, exist_ok=True)
os.makedirs(Path(VAR_DIR, "huey_files").resolve(), exist_ok=True)
env_file = Path(VAR_DIR, "env")
if not env_file.exists():
    secret = "".join(secrets.choice(string.ascii_letters) for _ in range(32))
@@ -46,6 +47,7 @@ JAMA_SHOW_RPC_DOCS = False if os.getenv("JAMA_SHOW_RPC_DOCS") != "1" else True
JAMA_USE_POSTGIS = True if os.getenv("JAMA_USE_POSTGIS") == "1" else False
JAMA_ROOT_URL_REDIRECT = os.getenv("JAMA_ROOT_URL_REDIRECT")
JAMA_CACHE_BACKEND = os.getenv("JAMA_CACHE_BACKEND") or "file"
JAMA_HUEY_CLASS = os.getenv("JAMA_HUEY_CLASS") or "huey.FileHuey"
JAMA_DB_ADAPTER = os.getenv("JAMA_DB_ADAPTER") or "sqlite"
JAMA_URL_BASE_PATH = os.getenv("JAMA_URL_BASE_PATH") or ""
JAMA_USE_MODSHIB = True if os.getenv("JAMA_USE_MODSHIB", "1") == "1" else False
@@ -312,11 +314,10 @@ INTERNAL_IPS = [
]

HUEY = {
    "huey_class": "huey.SqliteHuey",  # Huey implementation to use.
    "filename": Path(VAR_DIR, "huey.db").resolve(),
    "results": True,  # Store return values of tasks.
    "huey_class": JAMA_HUEY_CLASS,  # Huey implementation to use. Defaults to huey.FileHuey. Other possible values: huey.RedisHuey, huey.SqliteHuey
    "results": False,  # Store return values of tasks.
    "store_none": False,  # If a task returns None, do not save to results.
    "immediate": False,  # If DEBUG=True, run synchronously.
    "immediate": False,
    "utc": True,  # Use UTC for all times internally.
    "consumer": {
        "workers": 1,
@@ -331,6 +332,12 @@ HUEY = {
    },
}

if JAMA_HUEY_CLASS == "huey.SqliteHuey":
    HUEY["filename"] = str(Path(VAR_DIR, "huey.db").resolve())

if JAMA_HUEY_CLASS == "huey.FileHuey":
    HUEY["path"] = str(Path(VAR_DIR, "huey_files").resolve())

if JAMA_CACHE_BACKEND == "memcached":
    CACHES = {
        "default": {