Make await_client_ready() non-blocking.

This commit is contained in:
Itamar Turner-Trauring 2023-03-20 15:02:35 -04:00
parent ab300c090a
commit 61d9d82c55
6 changed files with 11 additions and 16 deletions

View File

@ -393,7 +393,7 @@ def alice(
finalize=False, finalize=False,
) )
) )
await_client_ready(process) pytest_twisted.blockon(await_client_ready(process))
# 1. Create a new RW directory cap: # 1. Create a new RW directory cap:
cli(process, "create-alias", "test") cli(process, "create-alias", "test")
@ -424,7 +424,7 @@ alice-key ssh-rsa {ssh_public_key} {rwcap}
# 4. Restart the node with new SFTP config. # 4. Restart the node with new SFTP config.
pytest_twisted.blockon(process.restart_async(reactor, request)) pytest_twisted.blockon(process.restart_async(reactor, request))
await_client_ready(process) pytest_twisted.blockon(await_client_ready(process))
print(f"Alice pid: {process.transport.pid}") print(f"Alice pid: {process.transport.pid}")
return process return process
@ -439,7 +439,7 @@ def bob(reactor, temp_dir, introducer_furl, flog_gatherer, storage_nodes, reques
storage=False, storage=False,
) )
) )
await_client_ready(process) pytest_twisted.blockon(await_client_ready(process))
return process return process

View File

@ -85,10 +85,6 @@ def test_large_file(alice, get_put_alias, tmp_path):
assert outfile.read_bytes() == tempfile.read_bytes() assert outfile.read_bytes() == tempfile.read_bytes()
@pytest.mark.skipif(
sys.platform.startswith("win"),
reason="reconfigure() has issues on Windows"
)
@ensureDeferred @ensureDeferred
async def test_upload_download_immutable_different_default_max_segment_size(alice, get_put_alias, tmpdir, request): async def test_upload_download_immutable_different_default_max_segment_size(alice, get_put_alias, tmpdir, request):
""" """

View File

@ -31,7 +31,7 @@ def test_upload_immutable(reactor, temp_dir, introducer_furl, flog_gatherer, sto
happy=7, happy=7,
total=10, total=10,
) )
util.await_client_ready(edna) yield util.await_client_ready(edna)
node_dir = join(temp_dir, 'edna') node_dir = join(temp_dir, 'edna')

View File

@ -42,8 +42,8 @@ if PY2:
def test_onion_service_storage(reactor, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl): def test_onion_service_storage(reactor, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl):
carol = yield _create_anonymous_node(reactor, 'carol', 8008, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) carol = yield _create_anonymous_node(reactor, 'carol', 8008, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl)
dave = yield _create_anonymous_node(reactor, 'dave', 8009, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl) dave = yield _create_anonymous_node(reactor, 'dave', 8009, request, temp_dir, flog_gatherer, tor_network, tor_introducer_furl)
util.await_client_ready(carol, minimum_number_of_servers=2) yield util.await_client_ready(carol, minimum_number_of_servers=2)
util.await_client_ready(dave, minimum_number_of_servers=2) yield util.await_client_ready(dave, minimum_number_of_servers=2)
# ensure both nodes are connected to "a grid" by uploading # ensure both nodes are connected to "a grid" by uploading
# something via carol, and retrieve it using dave. # something via carol, and retrieve it using dave.

View File

@ -570,6 +570,10 @@ def await_client_ready(tahoe, timeout=10, liveness=60*2, minimum_number_of_serve
We will try for up to `timeout` seconds for the above conditions We will try for up to `timeout` seconds for the above conditions
to be true. Otherwise, an exception is raised to be true. Otherwise, an exception is raised
""" """
return deferToThread(_await_client_ready_blocking, tahoe, timeout, liveness, minimum_number_of_servers)
def _await_client_ready_blocking(tahoe, timeout, liveness, minimum_number_of_servers):
start = time.time() start = time.time()
while (time.time() - start) < float(timeout): while (time.time() - start) < float(timeout):
try: try:
@ -792,16 +796,11 @@ async def reconfigure(reactor, request, node: TahoeProcess,
) )
if changed: if changed:
# TODO reconfigure() seems to have issues on Windows. If you need to
# use it there, delete this assert and try to figure out what's going
# on...
assert not sys.platform.startswith("win")
# restart the node # restart the node
print(f"Restarting {node.node_dir} for ZFEC reconfiguration") print(f"Restarting {node.node_dir} for ZFEC reconfiguration")
await node.restart_async(reactor, request) await node.restart_async(reactor, request)
print("Restarted. Waiting for ready state.") print("Restarted. Waiting for ready state.")
await_client_ready(node) await await_client_ready(node)
print("Ready.") print("Ready.")
else: else:
print("Config unchanged, not restarting.") print("Config unchanged, not restarting.")

0
newsfragments/3988.minor Normal file
View File