Skip to main content

Timeouts helper

Project description

timeouter

Timeout helper tools library for Python

Install

pip3 install timeouter

Examples

Simple class usage

import timeouter, time

t = timeouter.Timer(1)
time.sleep(0.5)
t.has(0.1) # True
t.has(0.6) # False
t.get() # returns remaining time
t.get(laps=3) # returns remaining time, split into 3 equal laps
t.reset() # resets timeout counter

# raises TimeoutError if timeout has expired, message is optional
t.check(message=message)

Custom timeout exception

Exception for the single timer object

class MyException(Exception): pass

t.set_exception_class(MyException)

Default exception for all new timers

class MyException(Exception): pass

timeouter.set_default_exception_class(MyException)

Thread-local usage

import timeouter as to

# init for the current thread
to.init(1)
time.sleep(2)
# module methods check, get, has, reset, set_timeout and set_exception_class
# are proxied to thread-local object
to.check()

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 timeouter, version 0.0.11
Filename, size File type Python version Upload date Hashes
Filename, size timeouter-0.0.11.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View hashes

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