{ "info": { "author": "gocept gmbh & co. kg", "author_email": "developers@gocept.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development" ], "description": "gocept.async provides asynchronous function calls using a decorator. It\nfacilitates ``lovely.remotetask`` to actually do things asynchronously.\n\n.. contents::\n\n\n\nDetails\n+++++++\n\nIt is often desirable to process computations asynchronously. Until there was\n`lovely.remotetask` this was not so easy to achieve in a Zope 3 application due\nto transaction integration issues.\n\n`gocept.async` makes the task even easier:\n\n>>> import gocept.async\n>>> @gocept.async.function(service='events')\n... def heavy_computing(a, b):\n... print \"Computing\", a, \"+\", b, \"=\", a + b\n\nThe decorator ``gocept.async.function`` takes exactly one argument, the name of\na lovely.remotetask.interfaces.ITaskService utility. Note that `gocept.async`\ndoes **not** define any task service by itself.\n\n\nTest Setup\n++++++++++\n\nNote that the decorated function must have an importable module to be usable:\n\n>>> import gocept.async.tests\n>>> heavy_computing.undecorated.__module__ = 'gocept.async.tests'\n>>> gocept.async.tests.heavy_computing = heavy_computing\n\nWe defined task-service called ``events`` in this test:\n\n>>> import zope.component\n>>> import lovely.remotetask\n>>> import lovely.remotetask.interfaces\n>>> import lovely.remotetask.processor\n>>> sm = zope.component.getSiteManager()\n>>> getRootFolder()['tasks'] = tasks = lovely.remotetask.TaskService()\n>>> tasks.processorFactory = lovely.remotetask.processor.MultiProcessor\n>>> tasks.processorArguments = {'maxThreads': 1}\n>>> sm.registerUtility(\n... tasks, lovely.remotetask.interfaces.ITaskService, name='events')\n\n\nBasics\n++++++\n\nWhen the decorated function is called it returns nothing:\n\n>>> heavy_computing(2, 7)\n\nWhen we start the processing of the task service, the function is called:\n\n>>> gocept.async.tests.process()\nComputing 2 + 7 = 9\n\nWhen the function is called while a user is logged in, the function will be\ncalled as that user (Note that it might be necessary to manually create\nsecurity proxies to enable security in the async function.):\n\n>>> @gocept.async.function('events')\n... def who_am_i():\n... print gocept.async.task.TaskDescription.get_principal()\n...\n>>> who_am_i.undecorated.__module__ = 'gocept.async.tests'\n>>> gocept.async.tests.who_am_i = who_am_i\n>>> who_am_i()\n>>> gocept.async.tests.process()\n\nNow login:\n\n>>> gocept.async.tests.login('zope.user')\n>>> who_am_i()\n>>> gocept.async.tests.process()\nzope.user\n>>> gocept.async.tests.logout()\n\n\nIf an async function is called while the process is already async'ed the\nfunction is called immediately:\n\n>>> @gocept.async.function(service='events')\n... def call_another():\n... print \"Before\"\n... heavy_computing(1, 2)\n... print \"After\"\n>>> call_another.undecorated.__module__ = 'gocept.async.tests'\n>>> gocept.async.tests.call_another = call_another\n>>> call_another()\n>>> gocept.async.tests.process()\nBefore\nComputing 1 + 2 = 3\nAfter\n\n\nThere is a helper to test if currenlty async is in progress:\n\n>>> gocept.async.is_async()\nFalse\n>>> @gocept.async.function(service='events')\n... def is_async_test():\n... print gocept.async.is_async()\n>>> is_async_test.undecorated.__module__ = 'gocept.async.tests'\n>>> gocept.async.tests.is_async_test = is_async_test\n>>> is_async_test()\n>>> gocept.async.tests.process()\nTrue\n\n\nTeardown\n++++++++\n\n>>> sm.registerUtility(\n... tasks, lovely.remotetask.interfaces.ITaskService, name='events')\n>>> del gocept.async.tests.heavy_computing\n>>> del gocept.async.tests.who_am_i\n>>> del gocept.async.tests.call_another\n>>> del gocept.async.tests.is_async_test\n\n\nChanges\n+++++++\n\n0.3.3 (2011-04-05)\n------------------\n\n- Replace deprecated zope.testing.doctest with stdlib's doctest.\n\n\n0.3.2 (2010-04-14)\n------------------\n\n- Fix conflict error logging.\n\n\n0.3.1 (2009-09-02)\n------------------\n\n- Extracted a function to determine wether a function is run asynchronously or\n not.\n\n\n0.3 (2009-07-31)\n----------------\n\n- Remember the site that was active when the async function was defined and\n restore it when it is run.\n\n0.2 (2009-04-16)\n----------------\n\n- Made it even less likely that tests will raise ConflictErrors.\n\n- Fixed tests in README.\n\n0.1.1 (2009-02-11)\n------------------\n\n- Made it less likely that tests will raise ConflictErrors.\n\n0.1 (2009-02-11)\n----------------\n\n- first internal release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/gocept.async", "keywords": "zope3 async asynchronous function", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "gocept.async", "package_url": "https://pypi.org/project/gocept.async/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/gocept.async/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/gocept.async" }, "release_url": "https://pypi.org/project/gocept.async/0.3.3/", "requires_dist": null, "requires_python": null, "summary": "Asynchronous function calls using lovely.remotetask", "version": "0.3.3" }, "last_serial": 2395122, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "8f6aabcdd3a1d6ce54c0f0cf97688efc", "sha256": "7e417112021fc7b93c402162e669d0908b916c9495c3e0a177aa4d551ea61e65" }, "downloads": -1, "filename": "gocept.async-0.2.tar.gz", "has_sig": false, "md5_digest": "8f6aabcdd3a1d6ce54c0f0cf97688efc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7462, "upload_time": "2009-04-16T12:59:35", "url": "https://files.pythonhosted.org/packages/3f/59/0165e80f423bb71ff4a3b219dcce87254b63165231d0e66810755580dd77/gocept.async-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "9de8eac59a2eacaba04eadf2f61901e5", "sha256": "52385c35de556609c9c4820bb1e8f72b3c7d770797a7536480d75ce02d051906" }, "downloads": -1, "filename": "gocept.async-0.3.tar.gz", "has_sig": false, "md5_digest": "9de8eac59a2eacaba04eadf2f61901e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7366, "upload_time": "2009-07-31T11:08:21", "url": "https://files.pythonhosted.org/packages/79/0c/b49ccbdd3372d3bceb3256613bedf228e271428b04b0b644059f12237060/gocept.async-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "b2e9fc04638ba9f11843ec076c826488", "sha256": "3f31a9d36d70b0e94feca7dcf7e33a68d697eb10b4bb6e83ed57baf6eb592719" }, "downloads": -1, "filename": "gocept.async-0.3.1.tar.gz", "has_sig": false, "md5_digest": "b2e9fc04638ba9f11843ec076c826488", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7727, "upload_time": "2009-09-02T19:33:12", "url": "https://files.pythonhosted.org/packages/c3/9e/a1b61acbc32b56fc8f0a10d780a289b86391606797ec73bb5a769995fd55/gocept.async-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "33689db9439224ac7c98e6be714a7982", "sha256": "f9a6b09efb56cfea81ed479aa09fae482bcb982056131d823bef0b20fda7c8ea" }, "downloads": -1, "filename": "gocept.async-0.3.2.tar.gz", "has_sig": false, "md5_digest": "33689db9439224ac7c98e6be714a7982", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7785, "upload_time": "2010-04-14T15:47:27", "url": "https://files.pythonhosted.org/packages/18/2f/66d62ed3a6d59089cf20945eae55864fbf20e7f4ec841cde1dbc4145a118/gocept.async-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "34487b5186338c4e07625d1e69dc4798", "sha256": "7b6fa34c0d775a4553ef99842da6c48535945804083ee4d65e58f5800499779b" }, "downloads": -1, "filename": "gocept.async-0.3.3.tar.gz", "has_sig": false, "md5_digest": "34487b5186338c4e07625d1e69dc4798", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7815, "upload_time": "2011-04-05T08:26:15", "url": "https://files.pythonhosted.org/packages/78/34/d7e9af3d4b343bf513aaf0ed389fa3b17c1c4d009ec767c6393d0c8642df/gocept.async-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "34487b5186338c4e07625d1e69dc4798", "sha256": "7b6fa34c0d775a4553ef99842da6c48535945804083ee4d65e58f5800499779b" }, "downloads": -1, "filename": "gocept.async-0.3.3.tar.gz", "has_sig": false, "md5_digest": "34487b5186338c4e07625d1e69dc4798", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7815, "upload_time": "2011-04-05T08:26:15", "url": "https://files.pythonhosted.org/packages/78/34/d7e9af3d4b343bf513aaf0ed389fa3b17c1c4d009ec767c6393d0c8642df/gocept.async-0.3.3.tar.gz" } ] }