Skip to main content

A watchdog for Gunicorn that interrupts long running requests.

Project description

MOOOOO!

Overview

Interruptingcow is a generic utility can relatively gracefully interrupt your Python code when it doesn’t execute within a specific number of seconds:

from interruptingcow import interruptingcow, InterruptedException

try:
    with interruptingcow(timeout=5):
        # perform a potentially very slow operation
        pass
except InterruptedException:
    print "didn't finish within 5 seconds"

Installation

$ pip install interruptingcow

Caveats

Interruptingcow uses signal(SIGALRM) to let the operating system interrupt program execution. This has the following limitations:

  1. SIGALRM is not reentrant so you can not nest timeouts

  2. Python signal handlers only apply to the main thread, so you cannot use this from other threads

  3. You must not use this in a program that uses SIGALRM itself

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

interruptingcow-0.1.tar.gz (11.6 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