On Tue, Dec 8, 2015 at 9:27 AM, <villasc...@gmail.com> wrote: > In regards to Chris's statement: "It openly and honestly does NOT reset its > state between page requests" > > With PHP, I have sessions to preserve state. I have a feeling that this is > significantly different. Yes? How? Does this somehow relate to how > websockets are implemented?
All three are very different. 1) Process state. You start up a Python program, and it sits there waiting for a request. You give it a request, and get back a response; it goes back to waiting for a request. If you change a global variable, or maintain persistent state, or anything, the next request will 'see' that change. This is completely global. 2) Sessions, cookies, and related concepts. A request comes in, and the response goes out "Hi! You're caller number 52635686412, and your call is important to us". Another request comes in from the same web browser, and the browser says "Hi! You said I was caller number 52635686412". The server looks up its information about that caller, which might be in a database, or on disk in the /tmp directory, or stored in process state (see above), or anything at all. This gives the appearance of per-client state, but it's all a simulation. 3) Websockets. A client makes a request saying "Hey, I want a websocket, please". The server says "Sure", and then they start maintaining true state. The socket would be broken if either the server or the client restarts (unlike sessions, although normally they're set up so a client restart will wipe the session). Websocket state is per-connection. Does that answer your question? The one I was talking about there was #1, process state. ChrisA -- https://mail.python.org/mailman/listinfo/python-list