{ "info": { "author": "Stephan Houben", "author_email": "stephanh42@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Build Tools" ], "description": "akitchensyncio\n==============\n\nUtility functions for asyncio which Stephan wished where in the stdlib\nbut aren't.\n\nRequires a Python version which supports the ``async`` syntax (Python\n3.5 or higher).\n\nInstallation\n============\n\nTo install akitchensyncio, simply:\n\n.. code:: bash\n\n $ pip install akitchensyncio\n\nFunction ``wrap_future(f)``\n---------------------------\n\nTakes a callable ``f`` which returns an awaitable, and returns a\ncallable which wraps the awaitable in ``asyncio.ensure_future``.\n\nCan also be used as a decorator, especially with coroutine functions:\n\n.. code:: python\n\n @wrap_future\n async def foo(arg1, arg2):\n ...\n\nThis is especially useful in combination with ``functools.lru_cache``.\nSuppose you have a coroutine function which does an asynchronous query,\nand you decide you want to introduce some caching. Just add two\ndecorators as follows.\n\n.. code:: python\n\n @functools.lru_cache(100)\n @wrap_future\n async def do_some_query(arg1, arg2):\n ...\n\nFunction ``transform_future(f, awaitable)``\n-------------------------------------------\n\nApply a function to the result of an awaitable, return a future which\ndelivers the result.\n\nAs an example, suppose you have a way to query addresses given names.\nThe API takes a bunch of names rather than a single one to reduce\noverhead. However, to your callers you would like to hand out futures\nrepresenting results for individual names.\n\nEssentially you want to turn a \"future resulting in a dict\" into a \"dict\ncontaining futures\". Kind of the opposite of ``async.gather``.\n\n.. code:: python\n\n from operator import itemgetter\n\n def query_addresses(names):\n fut = do_bunched_address_query(names)\n # fut is a single future which resolves\n # into a dict mapping names to addresses.\n return {name: transform_future(itemgetter(name), fut) for name in names}\n\nFunction ``iawait(awaitable)``\n------------------------------\n\n\"Interactive await\" -- Run default eventloop until awaitable has\ncompleted. Mainly useful for interactive experimentation.\n\nThen remove the \"i\" from ``iawait`` to get code which you can use in an\n``async def`` function.\n\nAn alternative is to put this in your ``~/.pythonrc.py``:\n\n.. code:: python\n\n def iawait(x):\n import asyncio\n loop = asyncio.get_event_loop()\n return loop.run_until_complete(x)\n\nThis will only import ``asyncio`` on first use of ``iawait``, so it\nwon't slow down your startup in general.\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/stephanh42/akitchensyncio", "keywords": "asyncio", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "akitchensyncio", "package_url": "https://pypi.org/project/akitchensyncio/", "platform": "", "project_url": "https://pypi.org/project/akitchensyncio/", "project_urls": { "Homepage": "https://github.com/stephanh42/akitchensyncio" }, "release_url": "https://pypi.org/project/akitchensyncio/0.1.1/", "requires_dist": null, "requires_python": "~=3.5", "summary": "Utility functions for asyncio which Stephan wished where in the stdlib but aren't.", "version": "0.1.1" }, "last_serial": 3196818, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "9505168291191605e85a8dae8c673f86", "sha256": "5e803c73ecbb7c77a02cdca6a1adf186ac4692de702993f65254243c370e2b73" }, "downloads": -1, "filename": "akitchensyncio-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9505168291191605e85a8dae8c673f86", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 3583, "upload_time": "2017-09-23T07:37:00", "url": "https://files.pythonhosted.org/packages/03/23/3ac87c0537499641a51bbca888d907bd8fbe745ab624e7c1376e4fe72487/akitchensyncio-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bd2f8ca0ff3d15656a794ac533a8ab72", "sha256": "204e198b05618bdae3e383aa290263355e74d376e408073896b2fcbf63231fff" }, "downloads": -1, "filename": "akitchensyncio-0.1.0.tar.gz", "has_sig": false, "md5_digest": "bd2f8ca0ff3d15656a794ac533a8ab72", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 2991, "upload_time": "2017-09-23T07:37:02", "url": "https://files.pythonhosted.org/packages/16/3b/8173abeb45cc4672f428d7d3447b3527a2306c901e868a8cf2fe12f8f25a/akitchensyncio-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a5db6e1288f21f8e89e318a867d798f3", "sha256": "58fb85a72d44f5e34d0ed11d13fa5ba5ce4388c084988f0c09192bbc715d1be5" }, "downloads": -1, "filename": "akitchensyncio-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a5db6e1288f21f8e89e318a867d798f3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 5048, "upload_time": "2017-09-23T10:11:10", "url": "https://files.pythonhosted.org/packages/1d/1b/ef17daf79bc8162a1dd3259988abda8af8ef7b9650a06cb1cb9bc923bdaa/akitchensyncio-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5cd26d83ac2fe25395b6e1a15b61e246", "sha256": "e416f5e36d27f5df8c52726b0691b55455dbbdbe97369b586a506cad25cf6eb4" }, "downloads": -1, "filename": "akitchensyncio-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5cd26d83ac2fe25395b6e1a15b61e246", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 5112, "upload_time": "2017-09-23T10:11:11", "url": "https://files.pythonhosted.org/packages/c9/51/f971b7b4a0d2b60dbcfd9f9c443b93d391dafb5b818f802b424fab8bfed5/akitchensyncio-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a5db6e1288f21f8e89e318a867d798f3", "sha256": "58fb85a72d44f5e34d0ed11d13fa5ba5ce4388c084988f0c09192bbc715d1be5" }, "downloads": -1, "filename": "akitchensyncio-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a5db6e1288f21f8e89e318a867d798f3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.5", "size": 5048, "upload_time": "2017-09-23T10:11:10", "url": "https://files.pythonhosted.org/packages/1d/1b/ef17daf79bc8162a1dd3259988abda8af8ef7b9650a06cb1cb9bc923bdaa/akitchensyncio-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5cd26d83ac2fe25395b6e1a15b61e246", "sha256": "e416f5e36d27f5df8c52726b0691b55455dbbdbe97369b586a506cad25cf6eb4" }, "downloads": -1, "filename": "akitchensyncio-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5cd26d83ac2fe25395b6e1a15b61e246", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.5", "size": 5112, "upload_time": "2017-09-23T10:11:11", "url": "https://files.pythonhosted.org/packages/c9/51/f971b7b4a0d2b60dbcfd9f9c443b93d391dafb5b818f802b424fab8bfed5/akitchensyncio-0.1.1.tar.gz" } ] }