{ "info": { "author": "NetAngels team", "author_email": "info@netangels.ru", "bugtrack_url": null, "classifiers": [], "description": "Celery tasktree module\n======================\n\ncelery-tasktree is a module which helps to execute trees of celery tasks\nasynchronously in a particular order. Tasktree comes to the rescue when the\nnumber of tasks and dependencies grows and when a naive callback-based approach\nbecomes hard to understand and maintain.\n\nUsage sample\n-------------\n\n::\n\n from celery_tasktree import task_with_callbacks, TaskTree\n\n @task_with_callbacks\n def some_action(...):\n ...\n\n def execute_actions():\n tree = TaskTree()\n task0 = tree.add_task(some_action, args=[...], kwargs={...})\n task1 = tree.add_task(some_action, args=[...], kwargs={...})\n task10 = task1.add_task(some_action, args=[...], kwargs={...})\n task11 = task1.add_task(some_action, args=[...], kwargs={...})\n task110 = task11.add_task(some_action, args=[...], kwargs={...})\n async_result = tree.apply_async()\n return async_result\n\n\nDecorator named ``task_with_callbacks`` should be used instead of simple celery\n``task`` decorator.\n\nAccording to the code:\n\n- task0 and task1 are executed simultaniously\n- task10 and task11 are executed simultaniously after task1\n- task110 is executed after task11\n\nThings to be noted:\n\n- There is no way to stop propagation of the execution and there is no way to\n pass extra arguments from an ancestor to a child task. In short, there in only one\n kind of dependency between tasks: the dependency of execution order.\n- If the subtask (function) return value is an object, then a property named\n \"async_result\" will be added to that object so that it will be possible to\n use ``join()`` to gather the ordered task results. To extend the previous example::\n\n async_result = execute_actions() \n task0_result, task1_result = async_result.join()\n task10_result, task11_result = task1_result.async_result.join()\n task110_result = task11_result.async_result.join() \n\nSubclassing `celery.task.Task` with callbacks\n----------------------------------------------\n\nDecorating functions with ``@task`` decorator is the easiest, but not the only\none way to create new ``Task`` subclasses. Sometimes it is more convenient to\nsubclass the generic ``celery.task.Task`` class and re-define its ``run()`` method.\nTo make such a class compatible with TaskTree, ``run`` should be wrapped with\n``celery_tasktree.run_with_callbacks`` decorator. The example below\nillustrates this approach::\n\n from celery.task import Task\n from celery_tasktree import run_with_callbacks, TaskTree\n\n class SomeActionTask(Task):\n\n @run_with_callbacks\n def run(self, ...):\n ...\n\n def execute_actions():\n tree = TaskTree()\n task0 = tree.add_task(SomeActionTask, args=[...], kwargs={...})\n task01 = task0.add_task(SomeActionTask, args=[...], kwargs={...})\n tree.apply_async()\n\n\nUsing TaskTree as a simple queue\n-----------------------------------\n\nIn many cases a fully fledged tree of tasks would be overkill for you. All you\nneed is to add two or more tasks to a queue to make sure that they will be\nexecuted in order. To allow this TaskTree has ``push()`` and ``pop()``\nmethods which in fact are nothing but wrappers around ``add_task()``.\nThe ``push()`` method adds a new task as a child to the perviously created one\nwhereas ``pop()`` removes and returns the task from the tail of the task stack.\nUsage sample looks like::\n\n # create the tree\n tree = TaskTree()\n # push a number of tasks into it\n tree.push(action1, args=[...], kwargs={...})\n tree.push(action2, args=[...], kwargs={...})\n tree.push(actionX, args=[...], kwargs={...})\n tree.pop() # get back action X from the queue\n tree.push(action3, args=[...], kwargs={...})\n # apply asynchronously\n tree.apply_async()\n\nActions will be executed in order ``action1 -> action2 -> action3``.\n\n\nTask with callbacks outside TaskTree\n---------------------------------------\n\nThe ``task_with_callbacks`` decorator can be useful in itself. It decorates\nfunctions the same way the ordinary ``task`` celery decorator does, but also\nadds an optional ``callback`` parameter.\n\nCallback can be a subtask or a list of subtasks (not the TaskSet). Behind the\nscenes, when a task with a callback is invoked, it executes the function's main code,\nthen builds a TaskSet, invokes it asynchronously and attaches the\n``TaskSetResut`` as the attribute named ``async_result`` to the function's return\nvalue.\n\nSimple example is provided below::\n\n from celery_tasktree import task_with_callbacks\n\n @task_with_callbacks\n def some_action(...):\n ...\n\n cb1 = some_action.subtask(...)\n cb2 = some_action.subtask(...)\n async_result = some_action.delay(..., callback=[cb1, cb2])\n main_result = async_result.wait()\n cb1_result, cb2_result = main_result.async_result.join()", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/NetAngels/celery-tasktree", "keywords": null, "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "celery-tasktree", "package_url": "https://pypi.org/project/celery-tasktree/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/celery-tasktree/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/NetAngels/celery-tasktree" }, "release_url": "https://pypi.org/project/celery-tasktree/0.3.4/", "requires_dist": null, "requires_python": null, "summary": "Celery Tasktree module", "version": "0.3.4" }, "last_serial": 1300800, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "5e8f47e2b839c2d53e468982c6faba28", "sha256": "c0b09b0baea549e3da5bd24e4a11fcb0ced0b0d997b8cc4fd940a7324857fe08" }, "downloads": -1, "filename": "celery-tasktree-0.1.tar.gz", "has_sig": false, "md5_digest": "5e8f47e2b839c2d53e468982c6faba28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2115, "upload_time": "2011-06-08T11:00:51", "url": "https://files.pythonhosted.org/packages/83/54/ee9d0433ec4aaebab231d3938e95629ee59c0c4d2dd65e694ba38cb9834a/celery-tasktree-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "8cd661c3f252d49db20919c60ffbb018", "sha256": "f58c04507e8b8ba8d5646c8affcb076f023a74d504124f16b1e4bdc810d59e5e" }, "downloads": -1, "filename": "celery-tasktree-0.2.tar.gz", "has_sig": false, "md5_digest": "8cd661c3f252d49db20919c60ffbb018", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2476, "upload_time": "2011-06-10T06:48:08", "url": "https://files.pythonhosted.org/packages/d4/f4/18a14cdc5f3711a63661faf30603844c3cfa3e97f0c0a3b14326263a8608/celery-tasktree-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "d6089238e0b80debd22c931c204a3fd2", "sha256": "347e04429de002e8db7e6611f24c9cc3d2fe64833e6efcf6881033c9e3e8e83f" }, "downloads": -1, "filename": "celery-tasktree-0.3.tar.gz", "has_sig": false, "md5_digest": "d6089238e0b80debd22c931c204a3fd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3148, "upload_time": "2011-06-16T08:08:15", "url": "https://files.pythonhosted.org/packages/d6/f3/a41e8dd6f08f16cbf39d30f5965abb5f8cb9520ec8855afbdb3b960fc84b/celery-tasktree-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "da36142e67e82fef8c7c5e8246cd2702", "sha256": "6655a0c9296349726bfbea4f54b4e4722f5320da9b9d86bba1a2e99629252ebe" }, "downloads": -1, "filename": "celery-tasktree-0.3.1.tar.gz", "has_sig": false, "md5_digest": "da36142e67e82fef8c7c5e8246cd2702", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3223, "upload_time": "2011-06-21T12:24:51", "url": "https://files.pythonhosted.org/packages/ce/61/ba62ce4366fda520fca3bb3e574c3961cc0e978eea249fb9a2318851c2dc/celery-tasktree-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "9df35008984c73f80e8df87d7d63ceb6", "sha256": "06be6b5f63bc2b5b252a9f210513d9b81e6813b099a554cb78e8754a1708774e" }, "downloads": -1, "filename": "celery-tasktree-0.3.2.tar.gz", "has_sig": false, "md5_digest": "9df35008984c73f80e8df87d7d63ceb6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3581, "upload_time": "2011-07-20T12:01:30", "url": "https://files.pythonhosted.org/packages/89/c4/59cbdfcd216d4b29b33d5f637d4152cd0c4dd78d245830218e7f53e43f47/celery-tasktree-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "a94e56c2e7f2b020a4b253d8d76c0596", "sha256": "4d01a80a17ff3b627f656bce4b90c0c918c09f946311f2b2a19446bf6691f9d0" }, "downloads": -1, "filename": "celery-tasktree-0.3.3.tar.gz", "has_sig": false, "md5_digest": "a94e56c2e7f2b020a4b253d8d76c0596", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3660, "upload_time": "2014-05-19T10:15:39", "url": "https://files.pythonhosted.org/packages/3c/b4/aadfc0c09023bbb3dc5f23c88a900ade3eff64f73375778fc211ce23d337/celery-tasktree-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "bf225e5fed5a7d929e511fab5b6e9032", "sha256": "fcb5cbd70566b7f95c356c9289ce4ad1843be22f2803939f833848f87eb5f734" }, "downloads": -1, "filename": "celery-tasktree-0.3.4.tar.gz", "has_sig": false, "md5_digest": "bf225e5fed5a7d929e511fab5b6e9032", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3650, "upload_time": "2014-11-10T10:24:47", "url": "https://files.pythonhosted.org/packages/ca/c0/ba560b82a9391e41e0a27f5e123126c910e7496d9c93dddb641c89894177/celery-tasktree-0.3.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bf225e5fed5a7d929e511fab5b6e9032", "sha256": "fcb5cbd70566b7f95c356c9289ce4ad1843be22f2803939f833848f87eb5f734" }, "downloads": -1, "filename": "celery-tasktree-0.3.4.tar.gz", "has_sig": false, "md5_digest": "bf225e5fed5a7d929e511fab5b6e9032", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3650, "upload_time": "2014-11-10T10:24:47", "url": "https://files.pythonhosted.org/packages/ca/c0/ba560b82a9391e41e0a27f5e123126c910e7496d9c93dddb641c89894177/celery-tasktree-0.3.4.tar.gz" } ] }