in chalice/cli/reloader.py [0:0]
def run_with_reloader(server_factory, env, root_dir, worker_process_cls=None):
# type: (Callable, MutableMapping, str, WorkerProcType) -> int
# This function is invoked in two possible modes, as the parent process
# or as a chalice worker.
try:
if env.get('CHALICE_WORKER') is not None:
# This is a chalice worker. We need to start the main dev server
# in a daemon thread and install a file watcher.
return start_worker_process(server_factory, root_dir,
worker_process_cls)
else:
# This is the parent process. It's just is to spawn an identical
# process but with the ``CHALICE_WORKER`` env var set. It then
# will monitor this process and restart it if it exits with a
# RESTART_REQUEST exit code.
start_parent_process(env)
except KeyboardInterrupt:
pass
return 0