Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_sibling_ria does not release IO handler resources properly #7583

Open
mih opened this issue Apr 22, 2024 · 0 comments
Open

create_sibling_ria does not release IO handler resources properly #7583

mih opened this issue Apr 22, 2024 · 0 comments
Labels
RIA/ORA Issues related to RIA-based workflows and related components

Comments

@mih
Copy link
Member

mih commented Apr 22, 2024

Here is the word-diff of what needs to change (i.e., wrapping the io object into a closing context manager).

Without this change, a remote shell (with SSHRemoteIO) is not properly closed until process/command exit.

diff --git a/datalad/distributed/create_sibling_ria.py b/datalad/distributed/create_sibling_ria.py
index 15ccd2df6..b43de0712 100644
--- a/datalad/distributed/create_sibling_ria.py
+++ b/datalad/distributed/create_sibling_ria.py
@@ -403,29 +403,29 @@ class CreateSiblingRia(Interface):
        #         command abstractions
        #       - more generally consider store creation a dedicated command or
        #         option
        [-io = SSHRemoteIO(ssh_host)-]{+from contextlib import closing+}
{+        with closing(SSHRemoteIO(ssh_host)+} if ssh_host else [-LocalIO()-]{+LocalIO()) as io:+}
            try:
                # determine the existence of a store by trying to read its layout.
                # Because this raises a FileNotFound error if non-existent, we need
                # to catch it
                io.read_file(local_base_path / 'ria-layout-version')
            except (FileNotFoundError, RIARemoteError, RemoteCommandFailedError) as e:
                if not new_store_ok:
                    # we're instructed to only act in case of an existing RIA store
                    res = get_status_dict(
                        status='error',
                        message="No store found at '{}'. Forgot "
                                "--new-store-ok ?".format(local_base_path),
                        **res_kwargs)
                    yield res
                    return

            log_progress(
                lgr.info, 'create-sibling-ria',
                'Creating a new RIA store at %s', local_base_path,
            )
            create_store(io, local_base_path, '1')

        yield from _create_sibling_ria(
            ds,
@mih mih added the RIA/ORA Issues related to RIA-based workflows and related components label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RIA/ORA Issues related to RIA-based workflows and related components
Projects
None yet
Development

No branches or pull requests

1 participant