Skip to main content

dj-loopbreaker

coverage PyPI version

Django library which breaks infinite loops in signals

Installation

pip install dj-loopbreaker

Usage

from loopbreaker import throttle

The problem

Imagine you have a signal like this:

@receiver(post_save, sender=Todo, dispatch_uid="example.say_hi")
@throttle(signal_id="update.todo", expire_after=1)
def update_todo(instance, created, **kwargs):
    # normally this would cause an infinte loop
    instance.done = not instance.done
    instance.save()

Normally that would cause an infinite loop. However, include the @throttle decorator, and it will now make sure that this signal is only executed again after 1 second for this specific instance.

How it works

throttle uses Django's caching mechanism. It will create a key using the following format: {signal_id}.{app_label}{model_name}{instance_id}. The key will expire after expire_after seconds

This means:

  • No longer need to worry about making infinite loops in your signals
  • No dependencies, or dependencies at your own discretion (we use django's internal caching, so you can set up your caching backend)
  • Throttling occurs per instance (not per model)

Metadata

Release files for dj-loopbreaker 0.0.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 dj-loopbreaker 0.0.1
File Size Uploaded Provenance
dj-loopbreaker-0.0.1.tar.gz 2.4 kB Without provenance Details

Release files / dj-loopbreaker-0.0.1.tar.gz

Download URL dj-loopbreaker-0.0.1.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8f29160a5811f25369aa9e02c39c1a1e7159ba4ae1db168553ca1f3d93fcc2d4
BLAKE2b-256 checksum
How to use checksums
b3b71f31795328a6df731e7cfb35c7955fb14fed7538a0e0ed655d7ae29bbef9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Security for dj-loopbreaker 0.0.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.0.1 This release

1 release file 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