debounce
Debounced function delays invoking the function until after wait seconds have
elapsed since the last time the debounced function was invoked. The debounced
function comes with a cancel method to cancel delayed function invocations
and a flush method to immediately invoke them.
Additional arguments
leading=True- If you want it to call your function immediately on invocation.max_wait=x- The maximum time the decorated function is allowed to be delayed before it's invoked.
Installation
pip install py-debounce
Usage
from debounce import debounce
@debounce(0.1)
def handle_event(e):
"""Computationally heavy methods that potentially gets polled a lot."""
Cancel
from debounce import debounce
@debounce(0.1)
def handle_event(e):
"""Computationally heavy methods that potentially gets polled a lot."""
# Imagine that the event has been called
handle_event(...)
# You can then cancel it by calling. The function will now never be called.
handle_event.cancel()
Flush
from debounce import debounce
@debounce(0.1)
def handle_event(e):
"""Computationally heavy methods that potentially gets polled a lot."""
# Imagine that the event has been called
handle_event(...)
# You can flush the call to immediately call it.
handle_event.flush()
Asyncio
It also handles async functions.
from debounce import debounce
@debounce(0.1)
async def event(e):
"""Computationally heavy methods that potentially gets polled a lot."""
Metadata
Release files for py-debounce 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_debounce-0.1.2.tar.gz | 17.6 kB | Without provenance | Details for py_debounce-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_debounce-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for py_debounce-0.1.2-py3-none-any.whl |
Total release size: 22.7 kB
Release files / py_debounce-0.1.2.tar.gz
| Download URL | py_debounce-0.1.2.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3253fde4bd00c02a0a9cfed72ba02e4a5a353bdf55544eea226b5532e0af20b8
|
|
BLAKE2b-256 checksum How to use checksums |
d8243d59b20ab8579a9cad675ae36fcae6176448912686e87f3086dd837bae9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / py_debounce-0.1.2-py3-none-any.whl
| Download URL | py_debounce-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d4b3a63d6b9c85851166b68d114f90ef0552d894ba805c37e0e733f394ab516
|
|
BLAKE2b-256 checksum How to use checksums |
e5dd53072abbc13429d7b964d59ef0b347a4620de5a2bcefa40b49372e493691
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for py-debounce 0.1.2
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.