Skip to main content

mywsgi

Setting up uWSGI for a new Python project is hard. uWSGI provides a million configuration options and a million ways to do everything. I have slimmed this down to a core set of basic options.

These options are very opinionated and how I've grown to like doing things.

Installation

pip install mywsgi

How do I

There are two APIs for working with mywsgi. A Python API, and a CLI API.

CLI

mywsgi comes along with a CLI interface. This is the simplest way to get going.

$ mywsgi --help
usage: mywsgi [-h] module bind

positional arguments:
  module      python wsgi module
  bind        ip:port to bind to

optional arguments:
  -h, --help  show this help message and exit
mywsgi foo.wsgi:application 127.0.0.1:8000

If you want to override or change any uWSGI variables, the only way to do this is through uWSGI's native environment variables. So something like:

export UWSGI_MAX_REQUESTS=1000
export UWSGI_HARAKIRI=30
mywsgi foo.wsgi:application 127.0.0.1:8000

Python API

The Python API is simple, it exposes one function with two required arguments.

import mywsgi
mywsgi.run(
    "foo.wsgi:application",
    "127.0.0.1:8000",
)

Running this ultimately execs out and hands off all control over to uWSGI. So beyond this call, nothing else will run. Your program is gone.

You can pass additional uWSGI arguments along to this as additional kwargs:

import mywsgi
mywsgi.run(
    "foo.wsgi:application",
    "127.0.0.1:8000"
    max_requests=10000,
    harakiri=30,
)

Anything passed in as kwargs is directly passed along to uWSGI and will override my defaults.

Bring your own uWSGI

This package does not directly require uWSGI, but it supports working with both the uWSGI package and the great pyuwsgi package.

I'd highly recommend using pyuwsgi instead of uWSGI directly. pyuwsgi is just a compiled binary distribution of uWSGI.

Release files for mywsgi 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mywsgi 1.0.3
File Size Uploaded
mywsgi-1.0.3.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mywsgi 1.0.3
File Interpreter ABI Platform
mywsgi-1.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 7.4 kB

Release files / mywsgi-1.0.3.tar.gz

Download URL mywsgi-1.0.3.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
16720914209c9191e0d1ad34f2ffa6c9959fb9a7ce899d12ad23ac3eab2c2e3b
BLAKE2b-256 checksum
How to use checksums
a3156a80b7694311b07163a743bd4aec34444396e56bc4d90e19bfcf9ff91432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / mywsgi-1.0.3-py2.py3-none-any.whl

Download URL mywsgi-1.0.3-py2.py3-none-any.whl
Size 4.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
846158e938f3ca3f6ad59ced34fd9dcf34c4ab059a60ff365bd3900d7878edcf
BLAKE2b-256 checksum
How to use checksums
151022b0b74b3b3021d5a94804eb9155c98c0d41101f7745548dc7af58a1a144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page