Skip to main content

A signal based timeout context manager

Project description

https://img.shields.io/travis/AntoineCezar/timeoutcontext.svg https://img.shields.io/badge/docs-latest-brightgreen.svg https://img.shields.io/coveralls/AntoineCezar/timeoutcontext.svg https://img.shields.io/pypi/v/timeoutcontext.svg

A signal based timeout context manager and decorator.

Usage

As a context manager:

from timeoutcontext import timeout, TimeoutException
from time import sleep

try:
    with timeout(1):
        sleep(2)
except TimeoutException:
    print('timeout')

As a decorator:

from timeoutcontext import timeout, TimeoutException
from time import sleep

@timeout(1)
def wait():
    sleep(2)

try:
    wait()
except TimeoutException:
    print('timeout')

License

  • Free software: BSD license

History

1.0.0 (2016-01-23)

  • First release on PyPI.

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

timeoutcontext-1.0.0.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

timeoutcontext-1.0.0-py2.py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 2 Python 3

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