Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>This answer is based off of new information that developed in the comments of @user590028's answer.</em></p> <p>You said that your goal is to have thread-safe persistant data. Because you also said you are familiarizing yourself with the WSGI specs, I feel this link is particularly relavant: <a href="http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Global_Variables" rel="nofollow">Application_Global_Variables</a></p> <blockquote> <p>...although global data can be used, it can only be used to cache data which can be safely reused within the context of that single process. You cannot use global data as a means of holding information that must be visible to any request handler no matter which process it runs in.</p> </blockquote> <p>Your application may not only be running under multiple threads, but potentially multiple processes. As per the above link, the recommended solution for persistant data (beyond that of the current request) is to use an external storage solution (filesystem, database, memcached, ...)</p> <h3>Update</h3> <p>What you are trying to do with locks in order to save state information seems completely unnecessary. Every request should be considered unique no matter what. If a client side user makes 10 requests to your application, and you want to persist data across those requests, then you should be using a session key like a cookie that you first establish to a client when their request is new (contains no session), and then you return it in the response and expect future requests to provide this key. Subsequently, there are libraries that aim to provide this functionality for you: <a href="http://www.ollycope.com/software/pesto/session.html" rel="nofollow">http://www.ollycope.com/software/pesto/session.html</a></p> <p>A wsgi application has an entry point, in these case your example defines it as a function called "application". It could also have been a class or anything callable. Your variables are context specific by nature because of the scope. Whatever you do with that scope is completely different from any other threads running that same handler. The "application" function could have been more complex, calling other functions and passing its variables around until ultimately returning its response body. You could also have created a class instance that contains all the functionality needed to process the request and generate the response, and making use of its own instance variables.</p> <p>And if neither of these previous two suggestions apply to what you are asking, I see the only remaining possibility being that you do actually want to store your data in a database, or filesystem, or memcached, or redis, and so on. uuid4 will be unique, but its value only has meaning if you pass it on in the response and have the client return it to remain associated to that data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload