Working With A Global Singleton In Flask (wsgi), Do I Have To Worry About Race Conditions?
The hello world demo for Flask is: from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello World!' if __name__ == '__main__': app.run()
Solution 1:
You could try the Local class from werkzeug. Here's some info about it: Context Locals
Example:
from flask import Flask
from werkzeug.local import Local
app = Flask(__name__)
loc = Local()
loc.a = 1
loc.b = 2
loc.c = 3@app.route("/")defhello():
loc.a += 1
loc.b += loc.a
loc.c += loc.b
return"Hello World!"if __name__ == "__main__":
app.run()
Post a Comment for "Working With A Global Singleton In Flask (wsgi), Do I Have To Worry About Race Conditions?"