def restart_reloader():
while True:
args = [sys.executable] + sys.argv
child_environ = os.environ.copy()
pid = os.fork()
# child process
if not pid:
child_environ["RUN_MAIN"] = "true"
# may exit with FILE_CHANGED code
# in fact, call itself
os.execve(sys.executable, args, child_environ)
# parent process
else:
signal_code = wait_child(pid)
handle_child_exit(signal_code)
# sample
# from wsgiref.simple_server import make_server
# def run():
# httpd = make_server(host='', port=8848, app=app)
# httpd.serve_forever()
# if __name__ == '__main__':
# autoreload(run)
评论列表
文章目录