我想要做的是检查启动事件的条件,如果发生执行,不要启动服务器或停止服务器。
@app.on_event("startup")
def startup_event():
public_key = None
try:
with open(PUBLIC_KEY_FILE) as public_key_file:
public_key = public_key_file.read()
except Exception as f_error:
logger.exception(f_error)
# cancel the startup
有没有办法做到这一点?