i'm adding flask support plugin-based application. on startup, app instantiates number of plugin classes. thought simple having flask kick off when class initialized, instead, whole app hangs when hits flask startup method.
consider following example:
#!/usr/bin/env python flask import flask class testclass: def __init__(self): print('initializing instance of testclass') self.app = flask(__name__) self.app.run() print("won't here until flask terminates!") foo = testclass()
the second print line won't evaluated until flask terminated.
is there sane way force app.run
background class continues initialization steps, while still having ability communicate flask throughout rest of class?
the app isn't "hanging", intention of app.run
start persistent server process runs until explicitly closed. should run setup logic before start server.
if need run tasks after app server process has initialized, can dispatch them in process celery.
Comments
Post a Comment