def on_pause():
     on_exception_delay = abdi_processargs.make_exception_delay_handler(
         args, reporter, None)
     on_exception_delay("until_file_removed")
def _process(args, reporter):

    retry_delays = abdi_processargs.get_retry_delays()

    repos = []
    for repo in args.repo_configs:
        parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
        abdi_processargs.setup_repo_arg_parser(parser)
        repo_name = repo[0]  # oddly this comes to us as a list
        repo_name = repo_name[1:]  # strip off the '@' prefix
        repo_args = (repo_name, parser.parse_args(repo))
        repos.append(repo_args)

    out = phlsys_statusline.StatusLine()

    # TODO: test write access to repos here

    operations = []
    conduits = {}
    url_watcher = phlurl_watcher.Watcher()
    for repo, repo_args in repos:

        process_func = functools.partial(
            abdi_processargs.run_once,
            repo,
            repo_args,
            out,
            reporter,
            conduits,
            url_watcher)

        on_exception_delay = abdi_processargs.make_exception_delay_handler(
            args, reporter, repo)
        operation = phlsys_scheduleunreliables.DelayedRetryNotifyOperation(
            process_func,
            list(retry_delays),  # make a copy to be sure
            on_exception_delay)

        operations.append(operation)

    def on_pause():
        on_exception_delay = abdi_processargs.make_exception_delay_handler(
            args, reporter, None)
        on_exception_delay("until_file_removed")

    operations.append(
        FileCheckOperation(
            args.kill_file,
            args.reset_file,
            args.pause_file,
            on_pause))

    operations.append(
        DelayedRetrySleepOperation(
            out, args.sleep_secs, reporter))

    operations.append(
        RefreshCachesOperation(
            conduits, url_watcher, reporter))

    if args.no_loop:
        def process_once():
            return phlsys_scheduleunreliables.process_once(list(operations))

        new_ops = tryHandleSpecialFiles(process_once, on_exception_delay)
        if new_ops != set(operations):
            print 'ERROR: some operations failed'
            sys.exit(1)
    else:
        def loopForever():
            phlsys_scheduleunreliables.process_loop_forever(list(operations))

        while True:
            tryHandleSpecialFiles(loopForever, on_exception_delay)