Skip to main content

Python ContextManager timeout handler library.

Project description


Python ContextManager timeout handler library.


$ pip install cmtimeout


Example 1:

from cmtimeout import CMTimeOut
import time

with CMTimeOut(2):
    print("this print never work!")

Example 2:

from cmtimeout import CMTimeOut

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

Example 3:

from cmtimeout import CMTimeOut, CMTimeOutException

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

NOTE: first argument (second) must be int.

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


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.

Source Distribution

cmtimeout-1.0.3.tar.gz (2.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page