farhawa
farhawa

Reputation: 10417

Django: global variables in multi-connections

I developed a django web-application and I tested it in local.. good news, it works!

Know I am trying to move forward. I want to make it reachable via public Internet.. Bad news, it won't work!

The client-side interact with server using Ajax and execute some python script and get some result to display in the web page.

The problem is that my application/server can't handle multiple connexions!!

I clarify:

Mainly, the problem is that when more than one client are served (2 for ex.), each one will ask the server to run a python script and, because there is a lot of global variables in the script, the two clients will modify them simultaneously and than bof!

Can multi-threading be a solution? How?

PS: It's clear, I am newbie to web :-). Thanks

Upvotes: 1

Views: 435

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599996

The answer is clear, surely: you should not be using global variables. If you need to store state for a user, do it in the session or the database.

Upvotes: 2

Related Questions