envvar
default PYL-W1508 82# https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor
83EXECUTOR = concurrent.futures.ProcessPoolExecutor(max_workers=WORKERS, mp_context=get_context(method=mp_method))
84DL_TIMEOUT = int(os.getenv("DL_TIMEOUT", 300))
85CHECK_URL_TIMEOUT = int(os.getenv("CHECK_URL_TIMEOUT", 30)) 86# Timeouts: https://www.python-httpx.org/advanced/
87COMMON_CONNECTION_TIMEOUT = int(os.getenv("COMMON_CONNECTION_TIMEOUT", 10))
88MAX_TG_FILE_SIZE = int(os.getenv("MAX_TG_FILE_SIZE", "45_000_000"))
71scdl_bin = local[os.path.join(BIN_PATH, "scdl")]
72bcdl_bin = local[os.path.join(BIN_PATH, "bandcamp-dl")]
73BCDL_ENABLE = False
74WORKERS = int(os.getenv("WORKERS", 2)) 75# TODO try to change to spawn or forkserver to save RAM
76mp_method = "fork"
77if platform.system() == "Windows":
81# https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
82# https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor
83EXECUTOR = concurrent.futures.ProcessPoolExecutor(max_workers=WORKERS, mp_context=get_context(method=mp_method))
84DL_TIMEOUT = int(os.getenv("DL_TIMEOUT", 300)) 85CHECK_URL_TIMEOUT = int(os.getenv("CHECK_URL_TIMEOUT", 30))
86# Timeouts: https://www.python-httpx.org/advanced/
87COMMON_CONNECTION_TIMEOUT = int(os.getenv("COMMON_CONNECTION_TIMEOUT", 10))
84DL_TIMEOUT = int(os.getenv("DL_TIMEOUT", 300))
85CHECK_URL_TIMEOUT = int(os.getenv("CHECK_URL_TIMEOUT", 30))
86# Timeouts: https://www.python-httpx.org/advanced/
87COMMON_CONNECTION_TIMEOUT = int(os.getenv("COMMON_CONNECTION_TIMEOUT", 10)) 88MAX_TG_FILE_SIZE = int(os.getenv("MAX_TG_FILE_SIZE", "45_000_000"))
89MAX_CONVERT_FILE_SIZE = int(os.getenv("MAX_CONVERT_FILE_SIZE", "80_000_000"))
90NO_FLOOD_CHAT_IDS = list(map(int, os.getenv("NO_FLOOD_CHAT_IDS", "0").split(",")))
Env manipulation functions return None
or str
values. Supplying anything different
as a default may cause bugs. See https://docs.python.org/3/library/os.html#os.getenv.
import os
indent = os.getenv("INDENT_LEVEL", default=4) # 4 is an int, but getenv gives strings
import os
indent_str = os.getenv("INDENT_LEVEL", default="4") # Now it's a string
indent = int(indent_str)