So here's an odd problem and an odd, probably bad, solution:
per what I had read here, my index.py just said:
and myapp.py contained all the logic for dispatch etc.:
etc. Changes to templates were reflected immediately in responses. But if I changed code in myapp.py, I had to re-save, or touch index.py before responses would reflect the changes. Very inconvenient for development purposes. I messed about quite a bit with httpd.conf, thinking it had something to do with WSGIDaemonProcess and suchlike, but to no avail. What I finally wound up doing strikes me as faintly ridiculous, and possibly harmful, though it works and can be removed for production. I revised index.py as follows:
There's a great deal I don't understand about how a wsgi app under flask works in the context of my webfaction environment. Can anyone tell me why I get this behavior; and, is there some more canonical way to fix it than calling an os process like this? asked 28 Jan '13, 15:55 jjon |
Touching your WSGI script is the canonical way to reload code when running under mod_wsgi - this is documented in the official mod_wsgi documentation: Reloading In Daemon Mode. Touching your WSGI script via answered 29 Jan '13, 16:20 seanf Thank you @seanf, that's exactly what I wanted to know. Thanks too for the link to the appropriate docs. It seemed to me too that it might cause problems down the road. So far, however, it's caused no trouble, and it will only be necessary for the development phase where I do a lot (way too much) of trial and error.
(29 Jan '13, 17:47)
jjon
|
Every time you change index.py or any .py file, you have to restart your HTTP server: navigate to /apache2/bin then "./restart" answered 28 Jan '13, 16:46 execute Well, actually, no. That's what I thought too when I started, but I found restarting apache every time I changed my python code really annoying. I discovered that since index.py script merely imports myapp, I just had to re-save or touch index.py to have any changes in myapp.py reflected in the response. So, I execute os.utime() each time index.py is requested. As I said, this does in fact work, but it seems weird and klugy to me. I was hoping someone could illuminate WHY it works, and whether or not there's a better, or more canonical way to do the same thing.
(29 Jan '13, 16:05)
jjon
|
Argh! Sorry for the noise. In my initial search I missed this, where @seanf helpfully explains about mod_wsgi in daemon mode. I'd still like to know, however, if using os.utime(), as I have here, has a downside that I haven't thought of.