Skip to main content

Opinionated uWSGI setup

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mywsgi-1.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

mywsgi-1.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file mywsgi-1.0.1.tar.gz.

File metadata

  • Download URL: mywsgi-1.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for mywsgi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 41430e68093db2ea7416fbaf27fe7c96ee829c8e7390b194e77cbdbcbd66fb75
MD5 63ea506001425797c23d42daa272a957
BLAKE2b-256 b92a1897f19936e4bf3a652cf4913929950c6d0d7dbb3fbbd4c2389cbbdb041a

See more details on using hashes here.

File details

Details for the file mywsgi-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mywsgi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for mywsgi-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b7f8cfd9916e01b309a94453fa8a67c0860f72e774d4f3417032e21a459e6c
MD5 ed4ec7219c10f81230dfc13f3a5fe4a8
BLAKE2b-256 c31943cab896904e0947709362466b5e87d7e69c252932015df478fcc20fbc8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page