如何优雅的在 FLASK 初始化 app 时提交一个后台任务?
資深大佬 : Latin 56
目前做法是这样,请各位大佬指教。
thread_lock = Lock() thread = None def create_app(): ... register_consumer(app) return app def register_consumer(app): global thread if not app.debug: with thread_lock: executor = ThreadPoolExecutor(1) thread = executor.submit(alarmHandle, app)
大佬有話說 (5)