Skip to main content

Fake uWSGI

Python Versions Test Status License Code Style https://deepsource.io/gh/digimach/fake-uwsgi.svg/?label=resolved+issues https://deepsource.io/gh/digimach/fake-uwsgi.svg/?label=active+issues https://scrutinizer-ci.com/g/digimach/fake-uwsgi/badges/quality-score.png?b=master CodeFactor https://codecov.io/gh/digimach/fake-uwsgi/branch/master/graph/badge.svg?token=HDF2UGHDPU

A Python module that attempts to fake out the uwsgi module exposed to uWSGI application. When testing applications outside uWSGI, for example Flask, this module can provide some functionality of the uwsgi module

fake_uwsgi attempts to replicate APIs and variables that the uwsgi module exposes to Python applications running in uWSGI.

Features

  • Provides the following uwsgi module APIs:
    • log

    • set_logvar

    • get_logvar

    • worker_id

    • workers

    • total_requests

  • Provides the following uwsgi module global variables:
    • numproc

    • opt

  • Sets the following environment variables:
    • INSTALL_PATH

    • APP_RUN_MODE

Quickstart

In order to make use of Fake uWSGI everywhere import uwsgi is used has to be replaced with:

try:
    # The following import will fail if not running in uWSGI
    import uwsgi  # pylint: disable=import-error
except ImportError:
    import fake_uwsgi as uwsgi  # pylint: disable-msg=ungrouped-imports

If your code makes use of other APIs and/or global variables that Fake uWSGI does not expose you have two options:

  1. Monkey patch or expand the fake_uwsgi module inside your code.

  2. Raise an feature request with this project.

Development

  1. This project uses tox to setup a development environment. Make sure you have tox installed:

    pip install tox
  2. Clone this repository

  3. You can setup the development environment by running the setup-dev make rule from the project directory:

    make setup-dev
  4. You can run tests by doing:

    make test
  5. To lint your code:

    make lint
  6. To format your code with Black run:

    make black

Metadata

Release files for fake-uwsgi 1.2.0

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

Source distribution (sdist)

Source distribution for fake-uwsgi 1.2.0
File Size Uploaded
fake-uwsgi-1.2.0.tar.gz 6.4 kB Details

Release files / fake-uwsgi-1.2.0.tar.gz

Download URL fake-uwsgi-1.2.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dc633daaa3fbfe009c3f9e1bee83be73be766f6dc426619453baf7d6e82cd38e
BLAKE2b-256 checksum
How to use checksums
78bacbd66a73cfa6f4295e5395727717fb9a6fd215fad5f12b802a3a33cd58b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file

1.1.0

2 release files

0.2.0

1 release file

0.1.0

1 release file

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