Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timeoutcontext

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timeoutcontext

A signal based timeout context manager

  • 1.2.0
  • PyPI
  • Socket score

Maintainers
1

============== Timeoutcontext

.. image:: https://img.shields.io/travis/AntoineCezar/timeoutcontext.svg :target: https://travis-ci.org/AntoineCezar/timeoutcontext

.. image:: https://img.shields.io/badge/docs-latest-brightgreen.svg :target: http://timeoutcontext.readthedocs.org/

.. image:: https://img.shields.io/coveralls/AntoineCezar/timeoutcontext.svg :target: https://coveralls.io/github/AntoineCezar/timeoutcontext

.. image:: https://img.shields.io/pypi/v/timeoutcontext.svg :target: https://pypi.python.org/pypi/timeoutcontext

A signal <https://docs.python.org/library/signal.html#>_ based timeout context manager and decorator.

Since it is signal based this package can not work under Windows operating system.

Usage

As a context manager:

.. code:: python

import sys
from time import sleep
from timeoutcontext import timeout
if sys.version_info < (3, 3):
    from timeoutcontext._timeout import TimeoutError

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

As a decorator:

.. code:: python

import sys
from time import sleep
from timeoutcontext import timeout
if sys.version_info < (3, 3):
    from timeoutcontext._timeout import TimeoutError

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

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

License

  • Free software: BSD license

History

1.2.0 (2018-03-11)

  • Allow sub-second timeout

1.1.1 (2016-09-05)

  • Fix README code exemples

1.1.0 (2016-09-05)

  • Add the "Not working on Windows operating system" notice
  • Rename TimeoutException to TimeoutError

1.0.0 (2016-01-23)

  • First release on PyPI.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc