Menu

Tree [af3af4] master /
 History

HTTPS access


File Date Author Commit
 .gitignore 2022-08-25 Ellery Alvarez Ellery Alvarez [e077a7] update compatibility info
 README.md 2021-02-22 Dave Brondsema Dave Brondsema [b15241] cleanup
 setup.cfg 2021-02-25 Dillon Walls Dillon Walls [b9c657] add setup.cfg for universal builds
 setup.py 2021-02-24 Dave Brondsema Dave Brondsema [ae1e14] Version 1.3 for python 3
 test_.py 2022-08-25 Ellery Alvarez Ellery Alvarez [e077a7] update compatibility info
 tox.ini 2023-09-14 Ellery Alvarez Ellery Alvarez [af3af4] Updated compatibility info with Python 3.12
 wsgipreload.py 2022-02-16 Dave Brondsema Dave Brondsema [e60298] Add requested-by=internal-preload to query stri...

Read Me

WSGI Preload

Preload your WSGI applications with specified URLs during startup.

Add this to the end of your .wsgi file:

:::python
import wsgipreload
wsgipreload.preload(application, urls=['/', '/foo', '/bar'])

If you are using mod_wsgi, specify the process-group and application-group on your WSGIScriptAlias directive so that it will preload properly. The process-group must match what you specify with WSGIProcessGroup in your config file. Details at https://modwsgi.readthedocs.io/en/develop/release-notes/version-3.0.html#features-added (section 2)

WSGIScriptAlias / /etc/httpd/conf.d/myapp.wsgi process-group=myapp application-group=%{GLOBAL}

Bonus! A helper function is included to pick a few URLs from the beginning of a log file. Use this if you don't want to hard-code all the URLs into your wsgi file.

:::python
import wsgipreload
urls = {'/'}
try:
    with open('/var/local/log/httpd-access_log') as log_file:
        urls |= wsgipreload.urls_from_log(log_file, num=5)
except Exception as e:
    print("preload error on logs")
    import traceback
    traceback.print_exc()

wsgipreload.preload(application, urls=urls)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.