import datetime
import functools
import logging
+import os
import platform
+import sys
import threading
import time
from typing import Callable, Optional
from kazoo.client import KazooClient
from kazoo.protocol.states import KazooState
-import config
import file_utils
import scott_secrets
logger = logging.getLogger(__name__)
+# On module load, grab what we presume to be our process' program name.
+# This is used, by default, as part of internal zookeeper paths (e.g.
+# to name a lease or election).
+PROGRAM_NAME: str = os.path.basename(sys.argv[0])
+
+
def obtain_lease(
f: Optional[Callable] = None,
*,
- lease_id: str = config.PROGRAM_NAME,
+ lease_id: str = PROGRAM_NAME,
contender_id: str = platform.node(),
initial_duration: datetime.timedelta = datetime.timedelta(minutes=5),
also_pass_lease: bool = False,
def run_for_election(
f: Optional[Callable] = None,
*,
- election_id: str = config.PROGRAM_NAME,
+ election_id: str = PROGRAM_NAME,
contender_id: str = platform.node(),
also_pass_zk_client: bool = False,
):