Python microagent compatibility

Compatibility Supported Not supported
Operating systems Linux, macOS 10.14 and 10.15 Solaris, Windows
Runtime versions CPython 2.7, and 3.4 - 3.8 JPython, PyPy
Web frameworks Django 1.6 and greater, Flask 0.10 and greater, Pyramid 1.6 and greater, aiohttp 2.2, 2.3 and 3.0 - 3.6 (see note below), Pylons Bottle, Tornado, web2py
Web app servers chaussette, gunicorn, uWSGI (see note below), waitress, most WSGI-compliant servers ASGI
Databases MongoDB, MySQL, PostgreSQL, SQLite MS SQL Server, Oracle
Templating engines Django, Jinja2 -
User monitoring Django, SDK for user monitoring -


The aiohttp server must use either the built-in asyncio event loop or the uvloop.


The Python agent is fully compatible with uWSGI servers. When using uWSGI, you must include several options. Refer to Python microagent compatibility for details.

uWSGI servers

The Python agent is fully compatible with uWSGI servers. When using uWSGI, you must include the following options:

  • --enable-threads: By default, uWSGI does not permit the creation of threads. You must enable them because the Python microagent uses threads.
  • --single-interpreter: By default, uWSGI loads every app in a new Python interpreter. You must ensure that your application and the Python microagent load on the same Python virtual machine.
  • --py-call-osafterfork: By default, uWSGI does not execute cleanup code on threads after forking. Enable this option because the Python microagent requires cleanup.
  • --master: If you use master mode on uWSGI and notice that Sqreen is not reporting data, enable the --lazy-apps option. By default, uWSGI pre-loads your application in a master process and this pre-loading could prevent the microagent from starting properly in the worker processes. If you still want to use pre-loading, use uwsgidecorators.postfork in your WSGI script instead of the sqreen-start CLI helper. This delays microagent startup after the master process has forked. Refer to the example below.
from uwsgidecorators import postfork

def delayed_start():
        import sqreen
    except ImportError:

Automatic user context in Python apps

The microagent automatically detects and protects user accounts when your application uses the Django framework. The Python microagent hooks the Django authenticate function.

Sqreen accepts any of the following argument values as Django users identifier:

  • username
  • email
  • user
  • mail
  • login
  • name
  • id
  • userid
  • user_id
  • identification

If your Sqreen Dashboard does not show any attempts at user authentication, check that your app is calling the standard Django authenticate function and that at least one keyword argument matches the list above and that its value is not None.

If your Python app uses a different framework, you can use the SDK for user monitoring to detect and protect user accounts.

Sqreen and NewRelic

The Sqreen microagent for Python and the NewRelic agent for Python agents are compatible.

  • If you use CLI helpers, put sqreen-start before newrelic-admin.

    sqreen-start newrelic-admin gunicorn ...

  • If you modify the WSGI file, import the Sqreen microagent before the NewRelic agent.

        import sqreen
    except ImportError:
        import newrelic.agent
    except ImportError:

Non-web applications

The microagent detects applications working without a web server at launch time. The microagent does not automatically run with:

  • tests launchers
  • iPython interpreters
  • celery workers
  • RQ workers
  • Django and Flask interactive interpreter ( shell).

If you want to disable Sqreen when launching an application, add the SQREEN_DISABLE=1 environment variable. See Configure for details.