mod_wsgi followup

14 views
Skip to first unread message

martha alvarez

unread,
Sep 1, 2021, 5:24:28 PMSep 1
to modwsgi
I figured out how to get it working but it is not making sense to me intuitively
I basically moved my py file contents to my wsgi file and took out my def application and instead included my connexion and add_api calls directly in it and ended it with application=app.app instead of a return and it works now:

app = connexion.App(__name__, specification_dir='./')
app.add_api(...)
...
application = app.app

It loads the amount of processes I have configured in my ssl.conf  (WSGIDaemonProcess ... processes=5) and it does not re-execute the add_api calls over and over after the first 5 requests are executed and those processes are loaded.

Graham Dumpleton

unread,
Sep 1, 2021, 5:29:04 PMSep 1
to mod...@googlegroups.com
Anything at global scope in the file is run once per process. Anything in the function is run once per request.

If you have multiple processes, then each process has to load it even if defined at global scope, so if lazy loading (default) is used, then you will see that delay as part of the first request time against each process.

You can force preloading of the WSGI script file in the process by using the configuration:

WSGIDaemonProcess mytest user=apache group=apache display-name=me-mytest processes=5
    WSGIScriptAlias /mytest /xxx/bin/mytest.wsgi process-group=mytest application-group=%{GLOBAL}
    <Directory "/xxx/bin">
        Require all granted
    </Directory>

That is, set both process-group and application-group on WSGIScriptAlias.

That will trigger the WSGI script file being loaded when the processes first start and not lazily on first request.

Graham

--
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 modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/e01a31a3-3934-4ef0-a7ef-11cad0437febn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages