We have a Flask-based mod_wsgi (4.6.4) app, apache 2.4.18 on Ubuntu 16.04LTS, using WSGIDaemonProcess, where WSGIScriptAlias points to the little ourapp.wsgi file which contains things like this:
sys.path.insert(0, "/srv/ourapp/modules") # a local path with some needed modules (but not some_good_module) import some_good_module # this is from a path already on sys.path via "python-path", and is on an autofs mount # if the above fails, an ImportError exception will be thrown, and the next line doesn't execute. application = make_outflaskapp() We've been have some trouble where the import line is failing on rare occasions. We think we have some sort of flakiness where the "some_good_module" resides on a mounted drive via autofs, which occasionally dismounts, and it isn't a mod_wsgi thing. But I'm curious what happens when ourapp.wsgi throws an exception like this before constructing the WSGI app and creating the "application" variable, and mod_wsgi takes over after the exception is thrown. It looks like it keeps that process it has created, with the Python interpreter that has been spun up in it, and will continue to try and execute the "ourapp.wsgi" code in it at later times? So the "sys.path.insert()" lines and anything above the exception point will be executed each time? We've caught subsequent executions of the code in that same process ID, with those path insertions stacked up, and eventually even when the filesystem mount causing the ImportError seems to be available again, the import still fails. I didn't think Python would cache a failed import name in any way, and would be looking to disk for the module file each time, and should succeed if the mount was there, but I'm still working on that, so the state of the mod_wsgi process is of interest. There isn't any option that can be set to cause mod_wsgi discard the process completely if it fails to get a WSGI app constructed in this case, instead of reusing it? -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/e2b193c2-9904-416b-8f91-63dab664a1ado%40googlegroups.com.
