Skip to main content

Python ContextManager timeout handler library.

Project description

CMTimeOut

Python ContextManager timeout handler library.

Install

$ pip install cmtimeout

Examples

Example 1:

from cmtimeout import CMTimeOut
import time

with CMTimeOut(2):
    time.sleep(3)
    print("this print never work!")

Example 2:

from cmtimeout import CMTimeOut

with CMTimeOut(2):
    with open("interface.fifo", "w") as f:
        pass

Example 3:

from cmtimeout import CMTimeOut, CMTimeOutException

try:
    with CMTimeOut(2, True):
        with open("interface.fifo", "w") as f:
            pass
except CMTimeOutException:
    print("opening file failed.")

NOTE: first argument (second) must be int.

NOTE: second argument enables or disables rasing exception when timeout exceeded.

Contribute

Kindly keep me posted in case of any issue or question by opening new file is issue page or send me a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
cmtimeout-1.0.3.tar.gz (2.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page