{ "info": { "author": "Emlyn O'Regan", "author_email": "emlynoregan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Distributed Computing" ], "description": "# appenginetaskutils\nThis is the repo for the appengine task utils library. It generates the appenginetaskutils package \n\n## Install\n\nUse the python package for this library. You can find the package online [here](https://pypi.python.org/pypi/appenginetaskutils).\n\nChange to your Python App Engine project's root folder and do the following:\n\n> pip install appenginetaskutils --target lib\n\nOr add it to your requirements.txt. You'll also need to set up vendoring, see [app engine vendoring instructions here](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27).\n\n## @task\n\nThe most basic element of the taskutils library is task(). This decorator function is designed to be used as a replacement for [deferred](https://cloud.google.com/appengine/articles/deferred).\n\n### Configuring @task\n\nWhen using deferred you have a builtin to configure in app.yaml to make it work. For taskutils.task, you need to add the following to your app.yaml and/or \\.yaml file:\n\n\thandlers:\n\t\t- url: /_ah/task/.*\n\t\t script: taskutils.app\n\t\t login: admin\n\nThis rule creates a generic handler for task to defer work to background push tasks.\n\nAdd it at the top of the list (to make sure other rules don't override it).\n\n### Importing task\n\nYou can import task into your modules like this:\n\n\tfrom taskutils import task\n\n### Using task as a decorator\n\nYou can take any function and make it run in a separate task, like this:\n\n\t@task\n\tdef myfunction():\n\t ... do stuff ... \n\nJust call the function normally, eg:\n\n\tmyfunction()\n\nYou can use @task on any function, including nested functions, recursive functions, recursive nested functions, the sky is the limit. This is possible because of use of [yccloudpickle](https://medium.com/the-infinite-machine/python-function-serialisation-with-yccloudpickle-b2ff6b2ad5da#.zei3n0ibu) as the underlying serialisation library.\n\nYour function can also have arguments, including other functions:\n\n\tdef myouterfunction(mapf):\n\n\t @task\n\t def myinnerfunction(objects):\n\t \tfor object in objects:\n\t \t\tmapf(object)\n\n\t ...get some list of lists of objects... \n\t\tfor objects in objectslist:\n\t\t\tmyinnerfunction(objects)\n\n\tdef dosomethingwithobject(object):\n\t\t... do something with an object ...\t\t\n\n\tmyouterfunction(dosomethingwithobject)\n\nThe functions and arguments are being serialised and deserialised for you behind the scenes.\n\nWhen enqueuing a background task, the App Engine Task and TaskQueue libraries can take a set of parameters. You can pass these to the decorator:\n\n\t@task(queue=\"myqueue\", countdown=5)\n\tdef anotherfunction():\n\t ... do stuff ... \n\nDetails of the arguments allowed to Tasks are available [here](https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.taskqueue), under **class google.appengine.api.taskqueue.Task(payload=None, \\*\\*kwargs)**. The task decorator supports a couple of extra ones, detailed below.\n\n### Using task as a factory\n\nYou can also use task to decorate a function on the fly, like this:\n\n\tdef somefunction(a, b):\n\t ... does something ...\n\n somefunctionintask = task(somefunction, queue=\"myqueue\")\n\nThen you can call the function returned by task when you are ready:\n\n somefunctionintask(1, 2)\n\nYou could do both of these steps at once, too:\n\n\n task(somefunction, queue=\"myqueue\")(1, 2)\n\n### transactional\n\nPass transactional=True to have your [task launch transactionally](https://cloud.google.com/appengine/docs/python/datastore/transactions#transactional_task_enqueuing). eg:\n\n\t@task(transactional=True)\n\tdef myserioustransactionaltask():\n\t ...\n\n### includeheaders\n\nIf you'd like access to headers in your function (a dictionary of headers passed to your task, it's a web request after all), set includeheaders=True in your call to @task. You'll also need to accept the headers argument in your function.\n\n\t@task(includeheaders=True)\n\tdef myfunctionwithheaders(amount, headers):\n\t ... stuff ...\n\n\tmyfunctionwithheaders(10)\n\nApp Engine passes useful information to your task in headers, for example X-Appengine-TaskRetryCount.\n\n### other bits\n\nWhen using deferred, all your calls are logged as /_ah/queue/deferred. But @task uses a url of the form /_ah/task/\\/\\, eg:\n\n\t/_ah/task/mymodule/somefunction\n\nwhich makes debugging a lot easier.\n\n\n\n\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/emlynoregan/im_task", "keywords": "", "license": "../LICENSE.txt", "maintainer": "", "maintainer_email": "", "name": "im-debouncedtask", "package_url": "https://pypi.org/project/im-debouncedtask/", "platform": "", "project_url": "https://pypi.org/project/im-debouncedtask/", "project_urls": { "Homepage": "https://github.com/emlynoregan/im_task" }, "release_url": "https://pypi.org/project/im-debouncedtask/0.1.0/", "requires_dist": [ "im-task" ], "requires_python": "", "summary": "@debouncedtask for google app engine, python standard environment", "version": "0.1.0" }, "last_serial": 3604414, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "ea6a27485e7751011b6194d309cb8e36", "sha256": "f0e5c33293b61a7fae40dc58ef6865301d693092e59142cff648940574931aaa" }, "downloads": -1, "filename": "im_debouncedtask-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ea6a27485e7751011b6194d309cb8e36", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7317, "upload_time": "2018-02-22T06:13:00", "url": "https://files.pythonhosted.org/packages/b1/c6/2561bc39b3337f95db549302ab511d2691c4f1a05bc990947d768d74eace/im_debouncedtask-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "50a9440ba033722567cecae37ed0689f", "sha256": "10c569ebe9410394016d73bcbddb678e851286dbf8f352205d0080f81d25f684" }, "downloads": -1, "filename": "im_debouncedtask-0.1.0.tar.gz", "has_sig": false, "md5_digest": "50a9440ba033722567cecae37ed0689f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4281, "upload_time": "2018-02-22T06:13:01", "url": "https://files.pythonhosted.org/packages/40/c0/2c2fdf3da8c85d2a0aa8ed50bfa85da9a9767a79ebd2f8f768781b4f3f4c/im_debouncedtask-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ea6a27485e7751011b6194d309cb8e36", "sha256": "f0e5c33293b61a7fae40dc58ef6865301d693092e59142cff648940574931aaa" }, "downloads": -1, "filename": "im_debouncedtask-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ea6a27485e7751011b6194d309cb8e36", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7317, "upload_time": "2018-02-22T06:13:00", "url": "https://files.pythonhosted.org/packages/b1/c6/2561bc39b3337f95db549302ab511d2691c4f1a05bc990947d768d74eace/im_debouncedtask-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "50a9440ba033722567cecae37ed0689f", "sha256": "10c569ebe9410394016d73bcbddb678e851286dbf8f352205d0080f81d25f684" }, "downloads": -1, "filename": "im_debouncedtask-0.1.0.tar.gz", "has_sig": false, "md5_digest": "50a9440ba033722567cecae37ed0689f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4281, "upload_time": "2018-02-22T06:13:01", "url": "https://files.pythonhosted.org/packages/40/c0/2c2fdf3da8c85d2a0aa8ed50bfa85da9a9767a79ebd2f8f768781b4f3f4c/im_debouncedtask-0.1.0.tar.gz" } ] }