What would be the logic behind having two (or more when I edit&save a file multiple times) copies of a imported module in memory, and "quite random which copy will be used"..? That sounds pretty weird to me.
For issue 2: I didn't know the global scope was only executed once on the first import, looks like a python feature I should accept :p On 9 jan, 22:34, GJ <[email protected]> wrote: > According to the documentations, both issues are caused by the fact > mod_wsgi keeps the Python interpreter loaded all the time for a > specific application group. When you first time request a script from > your web browser, the script is *imported* by mod_wsgi, executing any > code on the global scope of the script. Then mod_wsgi looks for the > name "application" and calls it. On any subsequent calls mod_wsgi > simply calls "application" again from the already loaded script, > unless it detects that the script file has been edited. > > 1. Now if your script imports some other files, then those are cached > too. If you edit them and they happen to be imported again, then you > have two copies of the imported module, new and old, and it is quite > random which copy will be used. By using the daemon mode and > "touch"ing the main script this problem can be worked around since the > process restarts itself causing also all other imported modules be > removed from memory also. > > 2. This case is even simpler. The start variable is assigned in global > scope, so it is only set to some value when the script was first time > imported. If you need to set every time, you must do it inside the > called "application" since that is the only code mod_wsgi will call > again on each request. Now I am not sure if setting run_once has any > effect on this, but I would not count on using that. > > On Jan 9, 10:34 pm, "bran.name" <[email protected]> wrote: > > > Hey all, > > > I seem to be having exactly the same problems: > > > 1. Sometimes getting old versions when refreshing a page, while I did > > edit file. > > - this first I did fix by writing a script that "touches" my wsgi > > script when I save a file in my IDE, as read > > at:http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode > > > 2. Some kind of caching of certain variables. > > - this I dont know how to fix yet, but I got to reproduce the problem > > fairly easy with the following code, executed as wsgi script: > > > import datetime > > start = datetime.datetime.now() > > def application(environment, start_response): > > start_response('200 OK', [('Content-Type', 'text/html; > > charset=utf8')]) > > return [str(datetime.datetime.now() - start)] > > > Exact Problem: Everytime I refresh the url to this page the time > > printed grows bigger, if I wait exactly 1 second between 2 refreshes, > > the time grows by exactly 1 second, there seems to be no end to it, I > > waited 2 days, and it incremented with 2 days more. The moment I touch > > the file or restart apache, the time printed is again the first > > request parse time, like I need it to be every refresh. The problem > > persists in both the mod_wsgi's embedded mode & daemon mode on all my > > test boxes seen below.
-- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
