1
0

cli: "./run_electrum daemon -d" to block until daemon becomes ready

Without this,
`$ python3 -m unittest electrum.tests.regtest.TestUnixSockets.test_unixsockets`
was failing on my machine but succeeding on CI, due to timing differences.
This commit is contained in:
SomberNight
2023-08-03 17:02:40 +00:00
parent 58a9904a34
commit 8b195ee77a
2 changed files with 21 additions and 2 deletions

View File

@@ -151,6 +151,19 @@ def request(config: SimpleConfig, endpoint, args=(), timeout: Union[float, int]
time.sleep(1.0)
def wait_until_daemon_becomes_ready(*, config: SimpleConfig, timeout=5) -> bool:
t0 = time.monotonic()
while True:
if time.monotonic() > t0 + timeout:
return False # timeout
try:
request(config, 'ping')
return True # success
except DaemonNotRunning:
time.sleep(0.05)
continue
def get_rpc_credentials(config: SimpleConfig) -> Tuple[str, str]:
rpc_user = config.RPC_USERNAME or None
rpc_password = config.RPC_PASSWORD or None