Skip to main content

Welcome to timelimiter

PyPI Python License: MIT codecov Tests

Python time limit library, using event loop to schedule job.

Resources:

Install

pip install timelimiter

Usage

  1. Extend TimeoutHandler with timeout expressed in seconds。Override _run method。MySQLTimeoutHandler for example.
from timelimiter.timeout_handler import TimeoutHandler, TimeoutHandlerFactory


class MySQLTimeoutHandler(TimeoutHandler):
    timeout = 0.5

    def __init__(self):
        super(MySQLTimeoutHandler, self).__init__()
        # Some way to get MySQL thread id
        self.thread_id = 1

    def _run(self):
        # Kill MySQL connection
        print(self.thread_id)


class MySQLTimeoutHandlerFactory(TimeoutHandlerFactory):
    def create_handler(self) -> TimeoutHandler:
        return MySQLTimeoutHandler()
  1. Use TimeLimiter to wrap the function。
from timelimiter.event_loop import start_loop
from timelimiter.time_limiter import TimeLimiter

start_loop()
factory = MySQLTimeoutHandlerFactory()

@TimeLimiter(factory)
def foo():
    # Do something
    ...

Configuration

Use environment to set configuration.

Name Description Default
TIME_LIMITER_CAPACITY Max capacity for time limiter queue 100,000

Run tests

make test

Author

👤 Keyes Hsu

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 Keyes Hsu.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Metadata

Release files for timelimiter 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for timelimiter 0.1.1
File Size Uploaded Provenance Actions
timelimiter-0.1.1.tar.gz 7.4 kB Without provenance Details for timelimiter-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for timelimiter 0.1.1
File Interpreter ABI Platform Actions
timelimiter-0.1.1-py3-none-any.whl Python 3 none any Details for timelimiter-0.1.1-py3-none-any.whl

Total release size: 14.8 kB

Release files / timelimiter-0.1.1.tar.gz

Download URL timelimiter-0.1.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b6543acd4d41197ad5a82e8cc8c426f398a13a49dd1a9d27496dc1a3ca03de75
BLAKE2b-256 checksum
How to use checksums
4759386544c8d1123349e212963946bdc681223b5a2e58547f729cf26faf3daf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / timelimiter-0.1.1-py3-none-any.whl

Download URL timelimiter-0.1.1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c1dc76531687ceeed66c22a0738d50a85b86a5ac15b4b338185d1534370f0d8
BLAKE2b-256 checksum
How to use checksums
83db2bb849f31da5415664baefbe65ea25d733abfec838a4280d7999cd68a3cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for timelimiter 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page