Skip to main content

A watchdog that interrupts long running code.

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.2.tar.gz (11.6 kB view details)

Uploaded Source

File details

Details for the file interruptingcow-0.2.tar.gz.

File metadata

  • Download URL: interruptingcow-0.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for interruptingcow-0.2.tar.gz
Algorithm Hash digest
SHA256 75eeb854ac5871e4115557448417fd734d94e7696348e4be294ed71fa2c94260
MD5 65a46aac2c09bfe3774d804f48443c97
BLAKE2b-256 dc796c6393e58f745f04ac802c4dd5c9f756507ec7f52cdf8b3c8af0282ff9fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page