Skip to main content

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.

Project description

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

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

fake-uwsgi-1.2.0.tar.gz (6.4 kB view hashes)

Uploaded Source

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