async def METHOD_NAME(runargs, mode):
    with TemporaryDirectory() as tmpdir:
        filename = os.path.join(tmpdir, "reloader.py")
        config_file = os.path.join(tmpdir, "config.json")
        runargs["reload_dir"] = tmpdir
        write_json_config_app(filename, config_file, **runargs)
        text = write_file(config_file)
        command = argv[mode]
        if mode == "sanic":
            command += ["--reload-dir", tmpdir]
        proc = Popen(command, cwd=tmpdir, stdout=PIPE, creationflags=flags)
        try:
            timeout = Timer(TIMER_DELAY, terminate, [proc])
            timeout.start()
            # Python apparently keeps using the old source sometimes if
            # we don't sleep before rewrite (pycache timestamp problem?)
            sleep(1)
            line = scanner(proc)
            assert text in next(line)
            # Edit source code and try again
            text = write_file(config_file)
            assert text in next(line)
        finally:
            timeout.cancel()
            terminate(proc)
            with suppress(TimeoutExpired):
                proc.wait(timeout=3)