{ "info": { "author": "Christo Crampton", "author_email": "tech@appointmentguru.co", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# dj-loopbreaker\n\n![coverage](https://gitlab.com/SchoolOrchestration/libs/dj-loopbreaker/badges/master/coverage.svg)\n[![PyPI version](https://badge.fury.io/py/dj-loopbreaker.svg)](https://badge.fury.io/py/dj-loopbreaker)\n\n> Django library which breaks infinite loops in signals\n\n## Installation\n\n```\npip install dj-loopbreaker\n```\n\n## Usage\n\n```python\nfrom loopbreaker import throttle\n```\n\n## The problem\n\nImagine you have a signal like this:\n\n```python\n@receiver(post_save, sender=Todo, dispatch_uid=\"example.say_hi\")\n@throttle(signal_id=\"update.todo\", expire_after=1)\ndef update_todo(instance, created, **kwargs):\n # normally this would cause an infinte loop\n instance.done = not instance.done\n instance.save()\n```\n\nNormally that would cause an infinite loop. However, include the `@throttle` decorator, and it will now make sure that this signal is only\nexecuted again after 1 second for this specific instance.\n\n## How it works\n\n`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\n\nThis means:\n\n* No longer need to worry about making infinite loops in your signals\n* No dependencies, or dependencies at your own discretion (we use django's internal caching, [so you can set up your caching backend](https://docs.djangoproject.com/en/2.1/topics/cache/#setting-up-the-cache))\n* Throttling occurs per instance (not per model)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/SchoolOrchestration/libs/dj-loopbreaker", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "dj-loopbreaker", "package_url": "https://pypi.org/project/dj-loopbreaker/", "platform": "", "project_url": "https://pypi.org/project/dj-loopbreaker/", "project_urls": { "Homepage": "https://gitlab.com/SchoolOrchestration/libs/dj-loopbreaker" }, "release_url": "https://pypi.org/project/dj-loopbreaker/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Break infinite loops in signals", "version": "0.0.1" }, "last_serial": 4355316, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "ae0f26ace9a1e3d9139d38dc8f596454", "sha256": "ba31e434dd1301a24d867ce5e1d2a4657019b6023c045c1ba1f8d4c67b4cbcaf" }, "downloads": -1, "filename": "dj-loopbreaker-0.0.0.tar.gz", "has_sig": false, "md5_digest": "ae0f26ace9a1e3d9139d38dc8f596454", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2436, "upload_time": "2018-09-20T14:25:07", "url": "https://files.pythonhosted.org/packages/42/32/8ba257e286a28434d92f075413bf4643f772aa28406b143ec82c9ba6ae0e/dj-loopbreaker-0.0.0.tar.gz" } ], "0.0.1": [ { "comment_text": "", "digests": { "md5": "c2e20c117a6194704467d585a7b878a2", "sha256": "8f29160a5811f25369aa9e02c39c1a1e7159ba4ae1db168553ca1f3d93fcc2d4" }, "downloads": -1, "filename": "dj-loopbreaker-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c2e20c117a6194704467d585a7b878a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2370, "upload_time": "2018-10-09T10:52:40", "url": "https://files.pythonhosted.org/packages/b3/b7/1f31795328a6df731e7cfb35c7955fb14fed7538a0e0ed655d7ae29bbef9/dj-loopbreaker-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2e20c117a6194704467d585a7b878a2", "sha256": "8f29160a5811f25369aa9e02c39c1a1e7159ba4ae1db168553ca1f3d93fcc2d4" }, "downloads": -1, "filename": "dj-loopbreaker-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c2e20c117a6194704467d585a7b878a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2370, "upload_time": "2018-10-09T10:52:40", "url": "https://files.pythonhosted.org/packages/b3/b7/1f31795328a6df731e7cfb35c7955fb14fed7538a0e0ed655d7ae29bbef9/dj-loopbreaker-0.0.1.tar.gz" } ] }