Skip to content

Instantly share code, notes, and snippets.

"""
This module provides very simple Django middleware that sleeps on every request.
This is useful when you want to simulate slow response times (as might be
encountered, say, on a cell network).
To use, add this middleware, and add a value for SLEEP_TIME to your settings.
New feature: Look for an X-Django-Sleep header on each request,
to let the client specify per-request sleep time. The header override your settings.