Hey this is a more general question.
The first part is just knowing exactly how Global variables work. If multiple users are accessing the server at the same time is a global variable going to be shared across all of the users? or will each user have their own instance of that global variable?
I am aware of sessions and how this is probably the best answer to solve my issue, however, I am currently working with the Django FormWizard and it doesnt seem to have access to request
so I am unable to use the sessions. I am not entirely sure how to access request
so if anyone knows how to do that I appreciate the help.
Thanks!
Depends on how you deploy your application. Gunicorn for example by default will load every worker process with its own environment, but with --preload
it will load app and only after that prefork workers. The second way global variables will be shared, but with a limitation: all shared variables will copy-on-write, so if you try to modify global variable in a worker process, that variable will be copied and you'll modify copy of instance.
Answering your second question. You cannot get request instance from anywhere you want in Django if it's not directly passed into function. Modifying global variables often isn't threadsafe, be aware.