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.

Files for cmtimeout, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size cmtimeout-1.0.3.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page