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

Timeout / max retries for sync command #56

Open
nickvergessen opened this issue Nov 2, 2015 · 0 comments
Open

Timeout / max retries for sync command #56

nickvergessen opened this issue Nov 2, 2015 · 0 comments

Comments

@nickvergessen
Copy link
Contributor

I'm currently writing smashbox based functional tests for our locking backend.
My first try was to sync and it is hanging infinite until 2.1 (to be released), due to the cmd retrying infinite times: owncloud/client#4037

Now I wrote a new method that sets a timeout:

    try:
        run_ocsync_timeout(d, seconds=10)
    except TimeoutError as err:
        # FIXME Issue raised https://github.com/owncloud/client/issues/4037
        logger.warning(err.message)

[...]


#  TODO move the block below into cernbox
class TimeoutError(Exception):
    pass


def handler(signum, frame):
    raise TimeoutError('Sync client did not terminate in time')


def run_ocsync_timeout(local_folder, remote_folder="", n=None, user_num=None, seconds=None):
    if seconds is not None:
        signal.signal(signal.SIGALRM, handler)
        signal.alarm(seconds)

    # This run_ocsync() may hang indefinitely
    run_ocsync(local_folder, remote_folder, n, user_num)

    if seconds is not None:
        signal.alarm(0)

Now my questions:

  1. Do you think it makes sense to add the timeout option to the default sync command?
  2. For new client versions --max-sync-retries support would be very nice to have. Can we add that to run_ocsync as well or should this be part of oc_sync_cmd? We can check if the client supports it by looking at --help:
    cmd = config.oc_sync_cmd
    if max_sync_retries is not None:
        help_cmd = cmd
        if help_cmd[0 - len(' --trust'):] == ' --trust':
            help_cmd = help_cmd[:0 - len(' --trust')]
        returncode, stdout, stderr = runcmd(help_cmd + ' --help', ignore_exitcode=True)

        try:
            if stdout.index('--max-sync-retries') is not None:
                cmd += ' --max-sync-retries %i' % max_sync_retries
        except ValueError:
            logger.warning('max-sync-retries ignored, because the client does not support it')

@moscicki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant