This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

It lets call any function with a timeout

Project Description

Timekiller

It lets call any function with a timeout!

Install

pip install timekiller

Link pypi: https://pypi.python.org/pypi/timekiller

Example

Call function

import timekiller
import time


def long_function(foo, bar):
    while True:
        time.sleep(10)
        print(foo, bar)

# call(func, max_time, *args, **kwargs)
timekiller.call(long_function, 5, "woo", bar="Uhmm")


@timekiller.timeout(5)
def long_function_with_decorator(foo, bar)
    while True:
        time.sleep(10)
        print(foo, bar)

long_function_with_decorator("woo", "Uhmm")

Capture exception

import timekiller
import time


@timeout(1)
def long_function():
    try:
        time.sleep(10)
    except timekiller.TimeoutException:
        print("capture exception")

long_function()

TODO: - It works in main thread and processes (not work in threads)

CHANGELOG

0.0.3 (2016-06-15)

  • Fix manifest.in
  • Fix pip install version

0.0.2 (2016-06-15)

  • Fix raise exception

0.0.1 (2016-06-14)

  • Initial version
Release History

Release History

This version
History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
timekiller-0.0.3.tar.gz (2.5 kB) Copy SHA256 Checksum SHA256 Source Jun 14, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting