Git Product home page Git Product logo

timeout.stuff's Introduction

Travis PyPI Documentation Status

โŒ› timeout.stuff, a simple timeout library

Have you ever wanted to make things timeout stuff after so much time has elapsed?

Do you have an SLA that dictates that if a certain function isn't performing up to snuff it doesn't reach a certain time limit

Installation

General use:

pip install timeout.stuff

Development:

  1. Fork the repo and clone your fork
  2. Run in the base repo:
python setup.py develop && pip install -r requirements-test.txt

Features

  • Context managers can be used to timeout code blocks if they reach a certain elapsed amount of time specified by the user
  • The same type of functionality can be used as a wrapper for functions

Examples

Use it on a code block!

Use it to timeout a block of code after a certain amount of elapsed time

import timeout


# Timeout this code block after 10 seconds has elapsed
with timeout.of(10):
    result = some_complex_stuff()
    some_more_complex_stuff(result)

Use it as a wrapper

Wrap functions that take a long time to do stuff and make sure they timeout correctly

import timeout


# Set some_complex_stuff to timeout after 10 seconds has elapsed
@timeout.after(10)
def some_complex_stuff():
    # Execute some complex behavior

some_complex_stuff()

Contributing

  1. Fork the repo
  2. Commit changes to your Fork
  3. Run python setup.py test and make sure those all pass
  4. Submit those changes as a Pull Request!

timeout.stuff's People

Contributors

seemethere avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.