{ "info": { "author": "Volumental", "author_email": "maintainer@volumental.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "# Django Leek\n![Logo](logo.svg)\n\n[![Build Status](https://travis-ci.com/Volumental/django-leek.svg?branch=master)](https://travis-ci.com/Volumental/django-leek)\n![Code Coverage](https://badges-io.now.sh/badge/Volumental/django-leek/coverage.svg)\n\nThe _simple_ and _slick_ way to run async tasks in Django.\n\n* Django-friendly API\n* Easy to start and stop\n\nBased on [django-queue](https://github.com/Aviah/django-queue).\n\n\n## Why?\nWith a healthy mix of vegetables, such as [Celery](celeryproject.org) and [Carrot](http://www.django-carrot.com/) aleady in the midst, what does `django-leek` bring?\n\nThe most \"lightweight\" library so far has \"install Redis\" as step one. Although, Redis is a fantastic software, sometimes you just want a simple way of offload the webserver and run a task async, such as sending an email.\n\nHere `django-leek` comes to the rescue. Usage and architecture cannot be simpler, and with so few moving parts, it should be very stable, although it's still not battle tested as e.g. Celery.\n\nWith `django-leek` you can get up and running quickly The more complex distributed queues can wait until the website has a lot of traffic, and the scalability is really required.\n\n## Getting started\n1. Install `django-leek` with pip\n\n\t```bash\n $ pip install django-leek\n\t````\n\n2. Add `django-leek` to `INSTALLED_APPS` in your `settings.py` file.\n\n3. Create tables needed\n\n ```bash\n\t$ manange.py migrate\n\t```\n\n4. Make sure the django-leek server is running.\n\n\t```bash\n\t$ python manage.py runleek\n\t```\n\n5. Go nuts\n\n ```python\n\tleek = Leek()\n\t@leek.task\n\tdef send_mail(to):\n\t do_what_ever()\n\n\tsend_mail.offload(to='foobar@example.com')\n\t```\n\n\tYou can also use the \"old\" as found in `django-queue`\n ```python\n\tpush_task_to_queue(send_mail, to='foobar@example.com')\t\n ```\n\n6. It's easy to unit test code that in production offloads work to the Leek server.\n\n\t```python\n\tdef _invoke(a_callable, *args, **kwargs):\n+ a_callable(*args, **kwargs)\n\t@patch('django_leek.api.push_task_to_queue', _invoke)\n\tdef test_mytest():\n\t\tsend_mail.offload(to='sync@leek.com') # now runs synchronously, like a normal function\n ```\n\n## Development\nThere is a test application you can play around with when developing on `django-leek`. Example:\n\n1. `./manage.sh test_app runserver` - Starts the test app\n2. `./manage.sh test_app leek` - Starts a leek instance for the test app\n3. `./manage.sh django_leek test` - Run test suite.\n\n## Technical overview\nIn a nutshell, a python SocketServer runs in the background, listening on a tcp socket. SocketServer gets the request to run a task from it's socket, puts the task on a Queue. A Worker thread picks tasks from this Queue, and runs the tasks one by one.\n\n### Components\n\n1. Python SocketServer that listens to a tcp socket.\n2. A Worker thread.\n3. A python Queue\n\n### Workflow\nThe workflow that runs an async task:\n\n1. When `SocketServer` starts, it initializes the `Worker` thread.\n2. `SocketServer` listens to requests.\n3. When `SocketServer` receives a request - a callables with args and kwargs - it puts the request on a python `Queue`.\n4. The `Worker` thread picks a task from the `Queue`.\n5. The `Worker` thread runs the task.\n\n### Can this queue scale to production?\nDepends on the traffic: SocketServer is simple, but solid, and as the site gets more traffic, it's possible to move the django-queue server to another machine, separate database etc. At some point, probably, it's better to pick Celery. Until then, django-leek is a simple, solid, and no-hustle solution. \n\n## Settings\nTo change the default django-queue settings, add a `LEEK` dictionary to your project main `settings.py` file.\n\nThis is the dictionary and the defaults:\n\n\tLEEK = {\n\t\t'bind': \"localhost:8002\",\n \t'host': \"localhost\",\n \t'port': 8002}\n\n**`bind`**\nThe leek server will bind here.\n\n**`host`**\nThe django server will connect to this host when notifying leek of jobs.\n\n**`port`**\nThe django server will connect to this port when notifying leek of jobs.\n\n## Persistence\nThe following models are used.\n\n**QueuedTasks** \nThe model saves every tasks pushed to the queue. \nThe task is pickled as a `tasks_queue.tasks.Task` object, which is a simple class with a `callable`,`args` and `kwargs` attributes, and one method: `run()`\n\n**SuccessTasks** \nThe Worker thread saves to this model the `task_id` of every task that was carried out successfuly. **task_id** is the task's `QueuedTasks` id.\n\n**FailedTasks** \nAfter the Worker tries to run a task and it fails by raising an exception, the Worker saves it to this model. The failed taks is saved by the `task_id`, with the exception message. Only the exception from the last run is saved.\n\n\n### Purge Tasks\n\nAccording to your project needs, you can purge tasks that the Worker completed successfuly.\n\nThe SQL to delete these tasks:\n\n\tDELETE queued,success\n\tFROM tasks_queue_queuedtasks queued\n\tINNER JOIN tasks_queue_successtasks success\n\tON success.task_id = queued.id;\n\nIn a similar way, delete the failed tasks.\nYou can run a cron script, or other script, to purge the tasks.\n\n## Release a new version\n1. Checkout master branch\n2. Make sure virtual environment is activated. `source venv/bin/activate`\n3. Make sure version in `setup.py` is correct. `grep version setup.py`\n4. Make sure setuptools, twine, and wheel are installed and up to date \n\n pip install \"setuptools>=38.6.0\" \"twine>=1.11.0\" \"wheel>=0.31.0\"\n\n5. Clean out any old dist packages. `rm -r dist/`\n6. Build source and wheel dists. `python setup.py sdist bdist_wheel`\n7. Upload to PyPI `twine upload dist/*`\n8. Profit!\n\n## Authors\nAviah, Silvia Scalisi and Samuel Carlsson\n\nSee [contributors]( https://github.com/Volumental/django-leek/graphs/contributors) for full list.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Volumental/django-leek", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-leek", "package_url": "https://pypi.org/project/django-leek/", "platform": "", "project_url": "https://pypi.org/project/django-leek/", "project_urls": { "Homepage": "https://github.com/Volumental/django-leek" }, "release_url": "https://pypi.org/project/django-leek/0.9.3/", "requires_dist": [ "django (>=1.11)" ], "requires_python": "", "summary": "A simple Django app to offload tasks from main web server", "version": "0.9.3" }, "last_serial": 4485343, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "b6c2c6cecb7f3097840b8e85528b9d7a", "sha256": "dac77bf92e1b97edfffc561f074c93d01abfd86cbaea587f5a9f7edb2411b349" }, "downloads": -1, "filename": "django_leek-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b6c2c6cecb7f3097840b8e85528b9d7a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10851, "upload_time": "2018-05-08T03:30:38", "url": "https://files.pythonhosted.org/packages/45/9e/e174ae71eb0b327d8b4ae2d37bfbcf58258d355568ab772e984d20b12e39/django_leek-0.2-py3-none-any.whl" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "059c44ccf57dcf1c8e4ef8c8897f4aa5", "sha256": "53da5881852b9a3ad3f2b0c15b028be922907157f552e703152934c984e3e8f9" }, "downloads": -1, "filename": "django_leek-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "059c44ccf57dcf1c8e4ef8c8897f4aa5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11681, "upload_time": "2018-05-08T04:14:32", "url": "https://files.pythonhosted.org/packages/6d/2f/268812c1c31e03e8a65c2962695e6199592e161d16125a10215c1986eea2/django_leek-0.3-py3-none-any.whl" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "08d3d034143c09c89425b09339d45847", "sha256": "b368e16f5f9613ddadbf96a34b6c25593fa5140fe2e49c7efd364a5fcae3e2c8" }, "downloads": -1, "filename": "django_leek-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "08d3d034143c09c89425b09339d45847", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12660, "upload_time": "2018-05-09T03:41:36", "url": "https://files.pythonhosted.org/packages/dc/72/8a2ccee959d701d1436ce68d5c10ea1ced10b199225c192bf690744c8d63/django_leek-0.4-py3-none-any.whl" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "d34eea189f3030bea79098fcc4a2ea35", "sha256": "fa164415f3b254d24a9127d63b54d26670b174eb9f4cfeb1186c61b0dd041166" }, "downloads": -1, "filename": "django_leek-0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "d34eea189f3030bea79098fcc4a2ea35", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12686, "upload_time": "2018-05-09T03:46:29", "url": "https://files.pythonhosted.org/packages/e5/4c/8372f1ccf24b279adcb54a92b4482a5c0df3b07307eb4152ebc2955aede6/django_leek-0.5-py3-none-any.whl" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "44c96f624200bb6e375444fc28a4d1f7", "sha256": "af00c3f60e82e7849ed446cd06c0aa5de71bca0f2e952f713ddff2b29e87e16f" }, "downloads": -1, "filename": "django_leek-0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "44c96f624200bb6e375444fc28a4d1f7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11562, "upload_time": "2018-06-01T09:57:03", "url": "https://files.pythonhosted.org/packages/37/7c/48814b6e2dd2a5b8dc6f6f8d0baef8a637da3048796d64d76f2fd1ed2718/django_leek-0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e62787c150e9f425a0e64da749a513c0", "sha256": "a68f6dccfa0a3051311a00a3ae81d55a40ce4a538e7f5f270634305740f06cb0" }, "downloads": -1, "filename": "django-leek-0.6.tar.gz", "has_sig": false, "md5_digest": "e62787c150e9f425a0e64da749a513c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7675, "upload_time": "2018-06-01T09:57:04", "url": "https://files.pythonhosted.org/packages/be/9b/5a95b8bafd2fe9d62d5f5ac1676c1758d0cd60bc33d12e2f56289617df5f/django-leek-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "f08416a73a7c8a05f62fed6e361fd645", "sha256": "6da46492ec8dda95a312661fba71de8fc05b3e6197365374b2dca46d14c58f8b" }, "downloads": -1, "filename": "django_leek-0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "f08416a73a7c8a05f62fed6e361fd645", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12036, "upload_time": "2018-09-05T13:50:58", "url": "https://files.pythonhosted.org/packages/7b/2c/3cc7d3d169d5bf93dd821aa419f4619f0e5ddade5ab9d20520d6f49b0ca3/django_leek-0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d6b4d7b71878d23ca500cde01116e7c2", "sha256": "15d8f865a2fd43985acfe88c1b6f66003037319d436cea03e52fa608230ccd1c" }, "downloads": -1, "filename": "django-leek-0.7.tar.gz", "has_sig": false, "md5_digest": "d6b4d7b71878d23ca500cde01116e7c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7914, "upload_time": "2018-09-05T13:50:59", "url": "https://files.pythonhosted.org/packages/85/14/75a820da2ea21d576cd69a88bedda67a3850242b59c23b6821c3a0dabd89/django-leek-0.7.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "70aaaa770bb735ae3db932fe36b6a079", "sha256": "7691fe9e9aa733b29a85ef8364e24df05da591ef6915e1f3e2c28c5ac15a4015" }, "downloads": -1, "filename": "django_leek-0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "70aaaa770bb735ae3db932fe36b6a079", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12156, "upload_time": "2018-09-07T09:13:34", "url": "https://files.pythonhosted.org/packages/63/4b/942237d23fa9154861abc8ddaa591efcb05f12a180f650f9ef6c5f18ae58/django_leek-0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e302c8b2ac81a4260e9970ed7490f03c", "sha256": "cd993258600b3963372098823e1046ac32128a1be5f9f753b916da8aa27cb2f8" }, "downloads": -1, "filename": "django-leek-0.8.tar.gz", "has_sig": false, "md5_digest": "e302c8b2ac81a4260e9970ed7490f03c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8010, "upload_time": "2018-09-07T09:13:36", "url": "https://files.pythonhosted.org/packages/59/49/76517468a51aeb38d74893be6961b8e83bb4e270a4a009300eea86153c0d/django-leek-0.8.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "ea444fe123cb019e79a4d9c118b2959c", "sha256": "c71cdfebc68a983d923a2b731cba7cad24d06b6239287149ba3d403b744f4230" }, "downloads": -1, "filename": "django_leek-0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "ea444fe123cb019e79a4d9c118b2959c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12723, "upload_time": "2018-09-10T15:49:34", "url": "https://files.pythonhosted.org/packages/df/63/c396fe1ab7c68cacafe9a092b61d3917d7fb65013a310f5c845f135206dd/django_leek-0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "628056507a611116263444fdc2b058eb", "sha256": "9c1bac3bf2fc2c559ff7598a467655ecea290f9bf2324b36cfaf8f6a065261e8" }, "downloads": -1, "filename": "django-leek-0.9.tar.gz", "has_sig": false, "md5_digest": "628056507a611116263444fdc2b058eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8168, "upload_time": "2018-09-10T15:49:36", "url": "https://files.pythonhosted.org/packages/16/b9/23c2d21537b21c02d4a50bd93697f1f8c4f3e683b5d7195fcac748afbbcb/django-leek-0.9.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "9366d7a8dcd7771876a6796ef877c4a3", "sha256": "19e4cbc8bef1267d4fe3b249a1eede2a21c2129e77a5cba738e92d565a19fae4" }, "downloads": -1, "filename": "django_leek-0.9.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9366d7a8dcd7771876a6796ef877c4a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12138, "upload_time": "2018-09-26T12:46:14", "url": "https://files.pythonhosted.org/packages/78/11/8390d8be6caf3125876dbab84a7935b77943ed704df7312fccef0148f687/django_leek-0.9.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d12b25efd2eed2056c0d5602673c240f", "sha256": "c85a26fcf516c2b718d1aeee4a092e9a55af76b31a1da1d845dffe24537b6725" }, "downloads": -1, "filename": "django-leek-0.9.1.tar.gz", "has_sig": false, "md5_digest": "d12b25efd2eed2056c0d5602673c240f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9756, "upload_time": "2018-09-26T12:46:16", "url": "https://files.pythonhosted.org/packages/51/62/de5b284c4b5d9683a6eb893a872de94d3b7a5b281007a629bbec0d46b4fc/django-leek-0.9.1.tar.gz" } ], "0.9.2": [ { "comment_text": "", "digests": { "md5": "07d1e695abfdc54098e0f746620884b5", "sha256": "44866dbfbe0e84ba00af526395c7811f52f2ba024e7359aeb0d5d0cab9e23743" }, "downloads": -1, "filename": "django_leek-0.9.2-py3-none-any.whl", "has_sig": false, "md5_digest": "07d1e695abfdc54098e0f746620884b5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13269, "upload_time": "2018-10-03T08:39:54", "url": "https://files.pythonhosted.org/packages/0f/0b/9c8de44bbf3de1f49dcc418a609ab70ed7fb79c349c720a1bff34b528504/django_leek-0.9.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8303e673d9039c3f1d4b89b6a5a6b7b3", "sha256": "4c01c25597e2ce2b0a23e7808231a229ab5cfa31566eaecead3473d7e909bc8e" }, "downloads": -1, "filename": "django-leek-0.9.2.tar.gz", "has_sig": false, "md5_digest": "8303e673d9039c3f1d4b89b6a5a6b7b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11069, "upload_time": "2018-10-03T08:39:56", "url": "https://files.pythonhosted.org/packages/2e/01/60336ad2c4e9b88d94aa69af916f1050cac4605434a84d7f795c61143fca/django-leek-0.9.2.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "94ca01552829ea8c6b1276045506e86a", "sha256": "2db1b37780d06f66a9a46d41605681de3ac07ca258e64762fb3e64bf6a23d053" }, "downloads": -1, "filename": "django_leek-0.9.3-py3-none-any.whl", "has_sig": false, "md5_digest": "94ca01552829ea8c6b1276045506e86a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13334, "upload_time": "2018-11-14T12:07:39", "url": "https://files.pythonhosted.org/packages/ab/e5/fb261e5e8b13a177a8d27bf4a48c9391f948e93ef5e1ca3a9b7457d755f7/django_leek-0.9.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "16ff00fdcea22018676440cc0b124366", "sha256": "341da1108b2d0aebf65d05dfb6c36855b4f4214c049d3e2e8e7edbb4bd959ef4" }, "downloads": -1, "filename": "django-leek-0.9.3.tar.gz", "has_sig": false, "md5_digest": "16ff00fdcea22018676440cc0b124366", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11103, "upload_time": "2018-11-14T12:07:42", "url": "https://files.pythonhosted.org/packages/5d/ec/3e8dcc4efb7d6eb7da243f0a379adbdcc8d82ad603e00f8c0d192e418487/django-leek-0.9.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "94ca01552829ea8c6b1276045506e86a", "sha256": "2db1b37780d06f66a9a46d41605681de3ac07ca258e64762fb3e64bf6a23d053" }, "downloads": -1, "filename": "django_leek-0.9.3-py3-none-any.whl", "has_sig": false, "md5_digest": "94ca01552829ea8c6b1276045506e86a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13334, "upload_time": "2018-11-14T12:07:39", "url": "https://files.pythonhosted.org/packages/ab/e5/fb261e5e8b13a177a8d27bf4a48c9391f948e93ef5e1ca3a9b7457d755f7/django_leek-0.9.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "16ff00fdcea22018676440cc0b124366", "sha256": "341da1108b2d0aebf65d05dfb6c36855b4f4214c049d3e2e8e7edbb4bd959ef4" }, "downloads": -1, "filename": "django-leek-0.9.3.tar.gz", "has_sig": false, "md5_digest": "16ff00fdcea22018676440cc0b124366", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11103, "upload_time": "2018-11-14T12:07:42", "url": "https://files.pythonhosted.org/packages/5d/ec/3e8dcc4efb7d6eb7da243f0a379adbdcc8d82ad603e00f8c0d192e418487/django-leek-0.9.3.tar.gz" } ] }