Are global variables thread safe in flask? How do I share data between requests?python-How to set global variables in Flask?Flask global variablesHow to set a global variable in python flask?how to handlde multiple concurrent request in flaskUsing variables across Flask routesUnable to share variables between 2 flasks requests in a view functionIn Python Flask: What are appropriate places to store data?Flask Server: Using a data in the same sessionFlask - get user input and pass it to backendFlask is serving app with singleton classIs local static variable initialization thread-safe in C++11?Get the data received in a Flask requestWhy are local variables thread safe in JavaHow to share the global app object in flask?How to have server call another server in Python with threading?Is reading a global collections.deque from within a Flask request safe?Handle Flask requests concurrently with threaded=TrueFlask POSTs with Trailing SlashFlask-SocketIo, How to share data between python thread and socketio.start_background_task thread?can't share variables between flask and threads
Tex Quotes(UVa 272)
What does zitch dog mean?
Transposing from C to Cm?
Did a flight controller ever answer Flight with a no-go?
How do you harvest carrots in creative mode?
How to prevent clipped screen edges on my TV, HDMI-connected?
Why is there so little discussion / research on the philosophy of precision?
Why do banks “park” their money at the European Central Bank?
Does Norwegian overbook flights?
Can RMSE and MAE have the same value?
Asymmetric table
Rent contract say that pets are not allowed. Possible repercussions if bringing the pet anyway?
Duplicate instruments in unison in an orchestra
Sum ergo cogito?
How do I make my image comply with the requirements of this photography competition?
Where can/should I, as a high schooler, publish a paper regarding the derivation of a formula?
"There were either twelve sexes or none."
What verb is かまされる?
Is gzip atomic?
Numbers Decrease while Letters Increase
Why doesn't 'd /= d' throw a division by zero exception?
Can a Rogue PC teach an NPC to perform Sneak Attack?
How to find out the average duration of the peer-review process for a given journal?
What is the difference between "Grippe" and "Männergrippe"?
Are global variables thread safe in flask? How do I share data between requests?
python-How to set global variables in Flask?Flask global variablesHow to set a global variable in python flask?how to handlde multiple concurrent request in flaskUsing variables across Flask routesUnable to share variables between 2 flasks requests in a view functionIn Python Flask: What are appropriate places to store data?Flask Server: Using a data in the same sessionFlask - get user input and pass it to backendFlask is serving app with singleton classIs local static variable initialization thread-safe in C++11?Get the data received in a Flask requestWhy are local variables thread safe in JavaHow to share the global app object in flask?How to have server call another server in Python with threading?Is reading a global collections.deque from within a Flask request safe?Handle Flask requests concurrently with threaded=TrueFlask POSTs with Trailing SlashFlask-SocketIo, How to share data between python thread and socketio.start_background_task thread?can't share variables between flask and threads
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In my app the state of a common object is changed by making requests, and the response depends on the state.
class SomeObj():
def __init__(self, param):
self.param = param
def query(self):
self.param += 1
return self.param
global_obj = SomeObj(0)
@app.route('/')
def home():
flash(global_obj.query())
render_template('index.html')
If I run this on my development server, I expect to get 1, 2, 3 and so on. If requests are made from 100 different clients simultaneously, can something go wrong? The expected result would be that the 100 different clients each see a unique number from 1 to 100. Or will something like this happen:
- Client 1 queries.
self.param
is incremented by 1. - Before the return statement can be executed, the thread switches over to client 2.
self.param
is incremented again. - The thread switches back to client 1, and the client is returned the number 2, say.
- Now the thread moves to client 2 and returns him/her the number 3.
Since there were only two clients, the expected results were 1 and 2, not 2 and 3. A number was skipped.
Will this actually happen as I scale up my application? What alternatives to a global variable should I look at?
python flask thread-safety
add a comment |
In my app the state of a common object is changed by making requests, and the response depends on the state.
class SomeObj():
def __init__(self, param):
self.param = param
def query(self):
self.param += 1
return self.param
global_obj = SomeObj(0)
@app.route('/')
def home():
flash(global_obj.query())
render_template('index.html')
If I run this on my development server, I expect to get 1, 2, 3 and so on. If requests are made from 100 different clients simultaneously, can something go wrong? The expected result would be that the 100 different clients each see a unique number from 1 to 100. Or will something like this happen:
- Client 1 queries.
self.param
is incremented by 1. - Before the return statement can be executed, the thread switches over to client 2.
self.param
is incremented again. - The thread switches back to client 1, and the client is returned the number 2, say.
- Now the thread moves to client 2 and returns him/her the number 3.
Since there were only two clients, the expected results were 1 and 2, not 2 and 3. A number was skipped.
Will this actually happen as I scale up my application? What alternatives to a global variable should I look at?
python flask thread-safety
add a comment |
In my app the state of a common object is changed by making requests, and the response depends on the state.
class SomeObj():
def __init__(self, param):
self.param = param
def query(self):
self.param += 1
return self.param
global_obj = SomeObj(0)
@app.route('/')
def home():
flash(global_obj.query())
render_template('index.html')
If I run this on my development server, I expect to get 1, 2, 3 and so on. If requests are made from 100 different clients simultaneously, can something go wrong? The expected result would be that the 100 different clients each see a unique number from 1 to 100. Or will something like this happen:
- Client 1 queries.
self.param
is incremented by 1. - Before the return statement can be executed, the thread switches over to client 2.
self.param
is incremented again. - The thread switches back to client 1, and the client is returned the number 2, say.
- Now the thread moves to client 2 and returns him/her the number 3.
Since there were only two clients, the expected results were 1 and 2, not 2 and 3. A number was skipped.
Will this actually happen as I scale up my application? What alternatives to a global variable should I look at?
python flask thread-safety
In my app the state of a common object is changed by making requests, and the response depends on the state.
class SomeObj():
def __init__(self, param):
self.param = param
def query(self):
self.param += 1
return self.param
global_obj = SomeObj(0)
@app.route('/')
def home():
flash(global_obj.query())
render_template('index.html')
If I run this on my development server, I expect to get 1, 2, 3 and so on. If requests are made from 100 different clients simultaneously, can something go wrong? The expected result would be that the 100 different clients each see a unique number from 1 to 100. Or will something like this happen:
- Client 1 queries.
self.param
is incremented by 1. - Before the return statement can be executed, the thread switches over to client 2.
self.param
is incremented again. - The thread switches back to client 1, and the client is returned the number 2, say.
- Now the thread moves to client 2 and returns him/her the number 3.
Since there were only two clients, the expected results were 1 and 2, not 2 and 3. A number was skipped.
Will this actually happen as I scale up my application? What alternatives to a global variable should I look at?
python flask thread-safety
python flask thread-safety
edited Jun 1 '18 at 16:38
davidism
71.7k13 gold badges207 silver badges210 bronze badges
71.7k13 gold badges207 silver badges210 bronze badges
asked Sep 28 '15 at 3:52
sayantankhansayantankhan
5711 gold badge6 silver badges13 bronze badges
5711 gold badge6 silver badges13 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can't use global variables to hold this sort of data. Not only is it not thread safe, it's not process safe, and WSGI servers in production spawn multiple processes. Not only would your counts be wrong if you were using threads to handle requests, they would also vary depending on which process handled the request.
Use a data source outside of Flask to hold global data. A database, memcached, or redis are all appropriate separate storage areas, depending on your needs. If you need to load and access Python data, consider multiprocessing.Manager
. You could also use the session for simple data that is per-user.
The development server may run in single thread and process. You won't see the behavior you describe since each request will be handled synchronously. Enable threads or processes and you will see it. app.run(threaded=True)
or app.run(processes=10)
. (In 1.0 the server is threaded by default.)
Some WSGI servers may support gevent or another async worker. Global variables are still not thread safe because there's still no protection against most race conditions. You can still have a scenario where one worker gets a value, yields, another modifies it, yields, then the first worker also modifies it.
If you need to store some global data during a request, you may use Flask's g
object. Another common case is some top-level object that manages database connections. The distinction for this type of "global" is that it's unique to each request, not used between requests, and there's something managing the set up and teardown of the resource.
add a comment |
This is not really an answer to thread safety of globals.
But I think it is important to mention sessions here.
You are looking for a way to store client-specific data. Every connection should have access to its own pool of data, in a threadsafe way.
This is possible with server-side sessions, and they are available in a very neat flask plugin: https://pythonhosted.org/Flask-Session/
If you set up sessions, a session
variable is available in all your routes and it behaves like a dictionary. The data stored in this dictionary is individual for each connecting client.
Here is a short demo:
from flask import Flask, session
from flask_session import Session
app = Flask(__name__)
# Check Configuration section for more details
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)
@app.route('/')
def reset():
session["counter"]=0
return "counter was reset"
@app.route('/inc')
def routeA():
if not "counter" in session:
session["counter"]=0
session["counter"]+=1
return "counter is ".format(session["counter"])
@app.route('/dec')
def routeB():
if not "counter" in session:
session["counter"] = 0
session["counter"] -= 1
return "counter is ".format(session["counter"])
if __name__ == '__main__':
app.run()
After pip install Flask-Session
, you should be able to run this. Try accessing it from different browsers, you'll see that the counter is not shared between them.
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
this is not working.
– Sibish
Aug 15 at 22:06
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32815451%2fare-global-variables-thread-safe-in-flask-how-do-i-share-data-between-requests%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't use global variables to hold this sort of data. Not only is it not thread safe, it's not process safe, and WSGI servers in production spawn multiple processes. Not only would your counts be wrong if you were using threads to handle requests, they would also vary depending on which process handled the request.
Use a data source outside of Flask to hold global data. A database, memcached, or redis are all appropriate separate storage areas, depending on your needs. If you need to load and access Python data, consider multiprocessing.Manager
. You could also use the session for simple data that is per-user.
The development server may run in single thread and process. You won't see the behavior you describe since each request will be handled synchronously. Enable threads or processes and you will see it. app.run(threaded=True)
or app.run(processes=10)
. (In 1.0 the server is threaded by default.)
Some WSGI servers may support gevent or another async worker. Global variables are still not thread safe because there's still no protection against most race conditions. You can still have a scenario where one worker gets a value, yields, another modifies it, yields, then the first worker also modifies it.
If you need to store some global data during a request, you may use Flask's g
object. Another common case is some top-level object that manages database connections. The distinction for this type of "global" is that it's unique to each request, not used between requests, and there's something managing the set up and teardown of the resource.
add a comment |
You can't use global variables to hold this sort of data. Not only is it not thread safe, it's not process safe, and WSGI servers in production spawn multiple processes. Not only would your counts be wrong if you were using threads to handle requests, they would also vary depending on which process handled the request.
Use a data source outside of Flask to hold global data. A database, memcached, or redis are all appropriate separate storage areas, depending on your needs. If you need to load and access Python data, consider multiprocessing.Manager
. You could also use the session for simple data that is per-user.
The development server may run in single thread and process. You won't see the behavior you describe since each request will be handled synchronously. Enable threads or processes and you will see it. app.run(threaded=True)
or app.run(processes=10)
. (In 1.0 the server is threaded by default.)
Some WSGI servers may support gevent or another async worker. Global variables are still not thread safe because there's still no protection against most race conditions. You can still have a scenario where one worker gets a value, yields, another modifies it, yields, then the first worker also modifies it.
If you need to store some global data during a request, you may use Flask's g
object. Another common case is some top-level object that manages database connections. The distinction for this type of "global" is that it's unique to each request, not used between requests, and there's something managing the set up and teardown of the resource.
add a comment |
You can't use global variables to hold this sort of data. Not only is it not thread safe, it's not process safe, and WSGI servers in production spawn multiple processes. Not only would your counts be wrong if you were using threads to handle requests, they would also vary depending on which process handled the request.
Use a data source outside of Flask to hold global data. A database, memcached, or redis are all appropriate separate storage areas, depending on your needs. If you need to load and access Python data, consider multiprocessing.Manager
. You could also use the session for simple data that is per-user.
The development server may run in single thread and process. You won't see the behavior you describe since each request will be handled synchronously. Enable threads or processes and you will see it. app.run(threaded=True)
or app.run(processes=10)
. (In 1.0 the server is threaded by default.)
Some WSGI servers may support gevent or another async worker. Global variables are still not thread safe because there's still no protection against most race conditions. You can still have a scenario where one worker gets a value, yields, another modifies it, yields, then the first worker also modifies it.
If you need to store some global data during a request, you may use Flask's g
object. Another common case is some top-level object that manages database connections. The distinction for this type of "global" is that it's unique to each request, not used between requests, and there's something managing the set up and teardown of the resource.
You can't use global variables to hold this sort of data. Not only is it not thread safe, it's not process safe, and WSGI servers in production spawn multiple processes. Not only would your counts be wrong if you were using threads to handle requests, they would also vary depending on which process handled the request.
Use a data source outside of Flask to hold global data. A database, memcached, or redis are all appropriate separate storage areas, depending on your needs. If you need to load and access Python data, consider multiprocessing.Manager
. You could also use the session for simple data that is per-user.
The development server may run in single thread and process. You won't see the behavior you describe since each request will be handled synchronously. Enable threads or processes and you will see it. app.run(threaded=True)
or app.run(processes=10)
. (In 1.0 the server is threaded by default.)
Some WSGI servers may support gevent or another async worker. Global variables are still not thread safe because there's still no protection against most race conditions. You can still have a scenario where one worker gets a value, yields, another modifies it, yields, then the first worker also modifies it.
If you need to store some global data during a request, you may use Flask's g
object. Another common case is some top-level object that manages database connections. The distinction for this type of "global" is that it's unique to each request, not used between requests, and there's something managing the set up and teardown of the resource.
edited Aug 16 '18 at 14:09
answered Sep 28 '15 at 14:26
davidismdavidism
71.7k13 gold badges207 silver badges210 bronze badges
71.7k13 gold badges207 silver badges210 bronze badges
add a comment |
add a comment |
This is not really an answer to thread safety of globals.
But I think it is important to mention sessions here.
You are looking for a way to store client-specific data. Every connection should have access to its own pool of data, in a threadsafe way.
This is possible with server-side sessions, and they are available in a very neat flask plugin: https://pythonhosted.org/Flask-Session/
If you set up sessions, a session
variable is available in all your routes and it behaves like a dictionary. The data stored in this dictionary is individual for each connecting client.
Here is a short demo:
from flask import Flask, session
from flask_session import Session
app = Flask(__name__)
# Check Configuration section for more details
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)
@app.route('/')
def reset():
session["counter"]=0
return "counter was reset"
@app.route('/inc')
def routeA():
if not "counter" in session:
session["counter"]=0
session["counter"]+=1
return "counter is ".format(session["counter"])
@app.route('/dec')
def routeB():
if not "counter" in session:
session["counter"] = 0
session["counter"] -= 1
return "counter is ".format(session["counter"])
if __name__ == '__main__':
app.run()
After pip install Flask-Session
, you should be able to run this. Try accessing it from different browsers, you'll see that the counter is not shared between them.
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
this is not working.
– Sibish
Aug 15 at 22:06
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
add a comment |
This is not really an answer to thread safety of globals.
But I think it is important to mention sessions here.
You are looking for a way to store client-specific data. Every connection should have access to its own pool of data, in a threadsafe way.
This is possible with server-side sessions, and they are available in a very neat flask plugin: https://pythonhosted.org/Flask-Session/
If you set up sessions, a session
variable is available in all your routes and it behaves like a dictionary. The data stored in this dictionary is individual for each connecting client.
Here is a short demo:
from flask import Flask, session
from flask_session import Session
app = Flask(__name__)
# Check Configuration section for more details
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)
@app.route('/')
def reset():
session["counter"]=0
return "counter was reset"
@app.route('/inc')
def routeA():
if not "counter" in session:
session["counter"]=0
session["counter"]+=1
return "counter is ".format(session["counter"])
@app.route('/dec')
def routeB():
if not "counter" in session:
session["counter"] = 0
session["counter"] -= 1
return "counter is ".format(session["counter"])
if __name__ == '__main__':
app.run()
After pip install Flask-Session
, you should be able to run this. Try accessing it from different browsers, you'll see that the counter is not shared between them.
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
this is not working.
– Sibish
Aug 15 at 22:06
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
add a comment |
This is not really an answer to thread safety of globals.
But I think it is important to mention sessions here.
You are looking for a way to store client-specific data. Every connection should have access to its own pool of data, in a threadsafe way.
This is possible with server-side sessions, and they are available in a very neat flask plugin: https://pythonhosted.org/Flask-Session/
If you set up sessions, a session
variable is available in all your routes and it behaves like a dictionary. The data stored in this dictionary is individual for each connecting client.
Here is a short demo:
from flask import Flask, session
from flask_session import Session
app = Flask(__name__)
# Check Configuration section for more details
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)
@app.route('/')
def reset():
session["counter"]=0
return "counter was reset"
@app.route('/inc')
def routeA():
if not "counter" in session:
session["counter"]=0
session["counter"]+=1
return "counter is ".format(session["counter"])
@app.route('/dec')
def routeB():
if not "counter" in session:
session["counter"] = 0
session["counter"] -= 1
return "counter is ".format(session["counter"])
if __name__ == '__main__':
app.run()
After pip install Flask-Session
, you should be able to run this. Try accessing it from different browsers, you'll see that the counter is not shared between them.
This is not really an answer to thread safety of globals.
But I think it is important to mention sessions here.
You are looking for a way to store client-specific data. Every connection should have access to its own pool of data, in a threadsafe way.
This is possible with server-side sessions, and they are available in a very neat flask plugin: https://pythonhosted.org/Flask-Session/
If you set up sessions, a session
variable is available in all your routes and it behaves like a dictionary. The data stored in this dictionary is individual for each connecting client.
Here is a short demo:
from flask import Flask, session
from flask_session import Session
app = Flask(__name__)
# Check Configuration section for more details
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)
@app.route('/')
def reset():
session["counter"]=0
return "counter was reset"
@app.route('/inc')
def routeA():
if not "counter" in session:
session["counter"]=0
session["counter"]+=1
return "counter is ".format(session["counter"])
@app.route('/dec')
def routeB():
if not "counter" in session:
session["counter"] = 0
session["counter"] -= 1
return "counter is ".format(session["counter"])
if __name__ == '__main__':
app.run()
After pip install Flask-Session
, you should be able to run this. Try accessing it from different browsers, you'll see that the counter is not shared between them.
edited May 27 at 8:57
answered Nov 5 '18 at 10:21
lhklhk
8,00212 gold badges64 silver badges99 bronze badges
8,00212 gold badges64 silver badges99 bronze badges
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
this is not working.
– Sibish
Aug 15 at 22:06
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
add a comment |
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
this is not working.
– Sibish
Aug 15 at 22:06
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
This is very cool! Why don't you set it up as its own Q&A?
– jtlz2
Apr 1 at 14:35
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
@jtlz2, thanks, I'm glad I could help you :D But setting this up as its own QA would feel like fishing for reputation. The docs for flask-session are awesome. I mean, if I create a separate question for this it would be called something like "is there something like server-side sessions in flask". And then, any google search that finds the new SO question, probably also shows you the official docs. So my contribution wouldn't really be useful and only compete for attention :P
– lhk
Jun 22 at 17:39
this is not working.
– Sibish
Aug 15 at 22:06
this is not working.
– Sibish
Aug 15 at 22:06
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
@Sibish, if you give me some details, I might be able to help you. It worked fine for me.
– lhk
Aug 17 at 18:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32815451%2fare-global-variables-thread-safe-in-flask-how-do-i-share-data-between-requests%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown