{ "info": { "author": "Jason Allum and Dave Martorana", "author_email": "jason@dmgctrl.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 6 - Mature" ], "description": "IMPORTANT: READ ME\r\n==================\r\n\r\nIn version 0.1.4, we are introducing two major changes:\r\n\r\n1. Tasks now have a \"created\" datetime field. This was added to make sure `--replayfailed` replayed tasks in the appropriate order\r\n2. Introduced [South](http://south.aeracode.org/) migrations.\r\n\r\nIF YOU HAVE ALREADY INSTALLED django-ztask - you can \"fake\" the first migration, and then run the second migration:\r\n\r\n ./manage.py migrate django_ztask --fake 0001\r\n ./manage.py migrate django_ztask\r\n \r\nIf you are not using [South](http://south.aeracode.org/) in your Django project, it is strongly recommended you do. If you\r\nare not, you will have to add the \"created\" field to your database manually.\r\n\r\nInstalling\r\n==========\r\n\r\nDownload and install 0MQ version 2.1.3 or better from [http://www.zeromq.org](http://www.zeromq.org)\r\n\r\nInstall pyzmq and django_ztaskd using PIP:\r\n\r\n pip install pyzmq\r\n pip install -e git+git@github.com:dmgctrl/django-ztask.git#egg=django_ztask\r\n\r\nAdd `django_ztask` to your `INSTALLED_APPS` setting in `settings.py`\r\n\r\n INSTALLED_APPS = (\r\n ...,\r\n 'django_ztask',\r\n )\r\n\r\nThen run `syncdb`\r\n\r\n python manage.py syncdb\r\n \r\n\r\nRunning the server\r\n==================\r\n\r\nRun django-ztask using the manage.py command:\r\n\r\n python manage.py ztaskd\r\n\r\n\r\nCommand-line arguments\r\n----------------------\r\n\r\nThe `ztaskd` command takes a series of command-line arguments:\r\n\r\n- `--noreload`\r\n \r\n By default, `ztaskd` will use the built-in Django reloader \r\n to reload the server whenever a change is made to a python file. Passing\r\n in `--noreload` will prevent it from listening for changed files.\r\n (Good to use in production.)\r\n\r\n- `-l` or `--loglevel`\r\n \r\n Choose from the standard `CRITICAL`, `ERROR`, `WARNING`, \r\n `INFO`, `DEBUG`, or `NOTSET`. If this argument isn't passed \r\n in, `INFO` is used by default.\r\n\r\n- `-f` or `--logfile`\r\n \r\n The file to log messages to. By default, all messages are logged\r\n to `stdout`\r\n\r\n- `--replayfailed`\r\n \r\n If a command has failed more times than allowed in the \r\n `ZTASKD_RETRY_COUNT` (see below for more), the task is\r\n logged as failed. Passing in `--replayfailed` will cause all \r\n failed tasks to be re-run.\r\n\r\n\r\nSettings\r\n--------\r\n\r\nThere are several settings that you can put in your `settings.py` file in \r\nyour Django project. These are the settings and their defaults\r\n\r\n ZTASKD_URL = 'tcp://127.0.0.1:5555'\r\n\r\nBy default, `ztaskd` will run over TCP, listening on 127.0.0.1 port 5555. \r\n\r\n ZTASKD_ALWAYS_EAGER = False\r\n\r\nIf set to `True`, all `.async` and `.after` tasks will be run in-process and\r\nnot sent to the `ztaskd` process. Good for task debugging.\r\n\r\n ZTASKD_DISABLED = False\r\n\r\nIf set, all tasks will be logged, but not executed. This setting is often \r\nused during testing runs. If you set `ZTASKD_DISABLED` before running \r\n`python manage.py test`, tasks will be logged, but not executed.\r\n\r\n ZTASKD_RETRY_COUNT = 5\r\n\r\nThe number of times a task should be reattempted before it is considered failed.\r\n\r\n ZTASKD_RETRY_AFTER = 5\r\n\r\nThe number, in seconds, to wait in-between task retries. \r\n\r\n ZTASKD_ON_LOAD = ()\r\n \r\nThis is a list of callables - either classes or functions - that are called when the server first\r\nstarts. This is implemented to support several possible Django setup scenarios when launching\r\n`ztask` - for an example, see the section below called **Implementing with Johnny Cache**.\r\n\r\n\r\nRunning in production\r\n---------------------\r\n\r\nA recommended way to run in production would be to put something similar to \r\nthe following in to your `rc.local` file. This example has been tested on \r\nUbuntu 10.04 and Ubuntu 10.10:\r\n\r\n #!/bin/bash -e\r\n pushd /var/www/path/to/site\r\n sudo -u www-data python manage.py ztaskd --noreload -f /var/log/ztaskd.log &\r\n popd\r\n\r\n\r\nMaking functions in to tasks\r\n============================\r\n\r\nDecorators and function extensions make tasks able to run. \r\nUnlike some solutions, tasks can be in any file anywhere. \r\nWhen the file is imported, `ztaskd` will register the task for running.\r\n\r\n**Important note: all functions and their arguments must be able to be pickled.**\r\n\r\n([Read more about pickling here](http://docs.python.org/tutorial/inputoutput.html#the-pickle-module))\r\n\r\nIt is a recommended best practice that instead of passing a Django model object \r\nto a task, you intead pass along the model's ID or primary key, and re-get \r\nthe object in the task function.\r\n\r\nThe @task Decorator\r\n-------------------\r\n\r\n from django_ztask.decorators import task\r\n\r\nThe `@task()` decorator will turn any normal function in to a \r\n`django_ztask` task if called using one of the function extensions.\r\n\r\nFunction extensions\r\n-------------------\r\n\r\nAny function can be called in one of three ways:\r\n\r\n- `func(*args, *kwargs)`\r\n\r\n Calling a function normally will bypass the decorator and call the function directly\r\n\r\n- `func.async(*args, **kwargs)`\r\n\r\n Calling a function with `.async` will cause the function task to be called asyncronously \r\n on the ztaskd server. For backwards compatability, `.delay` will do the same thing as `.async`, but is deprecated.\r\n\r\n- `func.after(seconds, *args, **kwargs)`\r\n\r\n This will cause the task to be sent to the `ztaskd` server, which will wait `seconds` \r\n seconds to execute.\r\n\r\n\r\nExample\r\n-------\r\n\r\n from django_ztask.decorators import task\r\n \r\n @task()\r\n def print_this(what_to_print):\r\n print what_to_print\r\n \r\n if __name__ == '__main__':\r\n \r\n # Call the function directly\r\n print_this('Hello world!')\r\n \r\n # Call the function asynchronously\r\n print_this.async('This will print to the ztaskd log')\r\n \r\n # Call the function asynchronously\r\n # after a 5 second delay\r\n print_this.after(5, 'This will print to the ztaskd log')\r\n \r\n\r\nImplementing with Johnny Cache\r\n==============================\r\n\r\nBecause [Johnny Cache](http://packages.python.org/johnny-cache/) monkey-patches all the Django query compilers, \r\nany changes to models in django-ztask that aren't properly patched won't reflect on your site until the cache \r\nis cleared. Since django-ztask doesn't concern itself with Middleware, you must put Johnny Cache's query cache\r\nmiddleware in as a callable in the `ZTASKD_ON_LOAD` setting.\r\n\r\n ZTASKD_ON_LOAD = (\r\n 'johnny.middleware.QueryCacheMiddleware',\r\n ...\r\n )\r\n\r\nIf you wanted to do this and other things, you could write your own function, and pass that in to \r\n`ZTASKD_ON_LOAD`, as in this example:\r\n\r\n**myutilities.py**\r\n\r\n def ztaskd_startup_stuff():\r\n '''\r\n Stuff to run every time the ztaskd server \r\n is started or reloaded\r\n '''\r\n from johnny import middleware\r\n middleware.QueryCacheMiddleware()\r\n ... # Other setup stuff\r\n\r\n**settings.py**\r\n \r\n ZTASKD_ON_LOAD = (\r\n 'myutilities.ztaskd_startup_stuff',\r\n ...\r\n )\r\n\r\n\r\nTODOs and BUGS\r\n==============\r\nSee: [http://github.com/dmgctrl/django-ztask/issues](http://github.com/dmgctrl/django-ztask/issues)", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/dmgctrl/django-ztask/tarball/0.1.5", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/dmgctrl/django-ztask", "keywords": "django zeromq 0mq background task", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-ztask", "package_url": "https://pypi.org/project/django-ztask/", "platform": "", "project_url": "https://pypi.org/project/django-ztask/", "project_urls": { "Download": "https://github.com/dmgctrl/django-ztask/tarball/0.1.5", "Homepage": "http://github.com/dmgctrl/django-ztask" }, "release_url": "https://pypi.org/project/django-ztask/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "Django ZTask - A simple background task scheduler for Django", "version": "0.1.5" }, "last_serial": 745721, "releases": { "0.1.4": [ { "comment_text": "", "digests": { "md5": "11ab5010e2fa95855381dd90c45cabf1", "sha256": "25094bf78f6b645c7c5bb9d044a30fdc79b575f0e5e4938bc55d7d28b08500e4" }, "downloads": -1, "filename": "django-ztask-0.1.4.tgz", "has_sig": false, "md5_digest": "11ab5010e2fa95855381dd90c45cabf1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7311, "upload_time": "2012-06-06T00:42:44", "url": "https://files.pythonhosted.org/packages/00/7b/1a9f6de6d13e2e3442afd4316a94a7a2e9103a7847797ff3f5d1eabc1a1a/django-ztask-0.1.4.tgz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "66939ca9d4a6070821b6728155651d33", "sha256": "aa6e93edbec8f26d74278c527e5dfd37df552927f5b22bd14a5072104f2ed3a6" }, "downloads": -1, "filename": "django-ztask-0.1.5.tgz", "has_sig": false, "md5_digest": "66939ca9d4a6070821b6728155651d33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7322, "upload_time": "2012-06-06T01:26:16", "url": "https://files.pythonhosted.org/packages/9d/0c/73a8f76476f384dec8625cbcd3522f5665fd482c0896a6920a8c0df90c33/django-ztask-0.1.5.tgz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "66939ca9d4a6070821b6728155651d33", "sha256": "aa6e93edbec8f26d74278c527e5dfd37df552927f5b22bd14a5072104f2ed3a6" }, "downloads": -1, "filename": "django-ztask-0.1.5.tgz", "has_sig": false, "md5_digest": "66939ca9d4a6070821b6728155651d33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7322, "upload_time": "2012-06-06T01:26:16", "url": "https://files.pythonhosted.org/packages/9d/0c/73a8f76476f384dec8625cbcd3522f5665fd482c0896a6920a8c0df90c33/django-ztask-0.1.5.tgz" } ] }