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
Release history Release notifications | RSS feed
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)