jmcore.tasks
jmcore.tasks
Shared async task utilities for JoinMarket components.
Provides common patterns for periodic background tasks used by both maker and taker components.
Functions
parse_directory_address(server: str, default_port: int = 5222) -> tuple[str, int]
Parse a directory server address string into host and port.
Args: server: Server address in "host:port" or "host" format default_port: Port to use if not specified (default: 5222)
Returns: Tuple of (host, port)
Source code in jmcore/src/jmcore/tasks.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
run_periodic_task(name: str, callback: Callable[[], Coroutine[Any, Any, None]], interval: float, initial_delay: float = 0.0, running_check: Callable[[], bool] | None = None) -> None
async
Run a callback periodically until cancelled or running_check returns False.
Args: name: Human-readable task name for logging callback: Async function to call each interval interval: Seconds between invocations initial_delay: Seconds to wait before first invocation running_check: Optional callable returning False to stop the task
Source code in jmcore/src/jmcore/tasks.py
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 43 44 45 46 47 | |