I have a google appengine app where I want to set a global variable for that request only. Can I do this?
In request_vars.py
# request_vars.py
global_vars = threading.local()
In another.py
# another.py
from request_vars import global_vars
get_time():
return global_vars.time_start
In main.py
# main.py
import another
from request_vars import global_vars
global_vars.time_start = datetime.datetime.now()
time_start = another.get_time()
Questions: Considering multithreading, concurrent requests, building on Google AppEngine, and hundreds (even thousands) of requests per second, will the value of time_start
always be equal to the value set in global_vars.time_start
in main.py
per request? Is this safe to use with multithreading/threadsafe enabled?