{ "info": { "author": "Felix Meyer-Wolters", "author_email": "felix@meyerwolters.de", "bugtrack_url": null, "classifiers": [], "description": "# aioexec\n\n## Description\n\nAioexec is a simple, intuitive interface around the `concurrent.futures` package and asyncio's `loop.run_in_executor` method. Aioexec is leightweight, no dependencies and ~100 LOC.\n\n## Requirements\n\naioexec requires Python `>= 3.6`\n\n## Install\n\n pip install aioexec\n\nor\n\n pipenv install aioexec\n\n## Usage\n\n**Without** `aioexec` you usually run an executor something like this:\n\n```python\nimport aysncio\nfrom concurrent.futures import ProcessPoolExecutor\n\n# ...\n\nloop = asyncio.get_event_loop()\n\nfoo = await loop.run_in_executor(\n ProcessPoolExecutor(1), lambda: my_func(foo='baz')\n)\n```\n\n**With** `aioexec` you would do the same like this:\n\n```python\nfrom aioexec import Procs\n\n# ...\n\nfoo = await Procs(1).call(my_func, foo='baz')\n```\n\nYou can call a `batch` of functions in the same executor like this:\n\n```python\nimport asyncio\nfrom aioexec import Procs, Call\n\n# ...\n\nmy_values = await asyncio.gather(\n *Procs(3).batch(\n Call(my_func, foo='bar'),\n Call(my_func, foo='baz'),\n Call(my_func, foo='qux'),\n )\n)\n```\n\nThis plays nicely with comprehensions:\n\n```python\nimport asyncio\nfrom aioexec import Procs, Call\n\n# ...\n\nmy_values = await asyncio.gather(\n *Procs(10).batch(\n Call(my_func, foo=i) for i in range(0, 10)\n )\n)\n```\n\nYou can also spawn a `pool` and make multiple different calls with the same executor:\n\n```python\nimport asyncio\nfrom aioexec import Procs, Call\n\n# ...\n\nwith Procs(10) as pool:\n\n value_a = await pool.call(my_func, foo='baz')\n\n value_b = await aio.gather(\n *pool.batch(\n Call(my_func, foo=i) for i in range(0, 10)\n )\n )\n\n # etc...\n```\n\nThe examples from above work the same for `Threads`, e.g.:\n\n```python\nfrom aioexec import Threads\n\n# ...\n\nfoo = await Threads(1).call(my_func, foo='baz')\n\n```\n\nIf necessary, you can pass an event `loop` to the executors like this:\n\n```python\nfoo = await Threads(1, my_loop).call(my_func, foo='baz')\nfoo = await Procs(1, my_loop).call(my_func, foo='baz')\n```\n\n## Development / Testing\n\nClone the repo and install dev packages:\n\n pipenv install --dev\n\nRun tests:\n\n pipenv run python make.py test\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/feluxe/aioexec/tarball/0.4.0", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/feluxe/aioexec", "keywords": "", "license": "unlicensed", "maintainer": "Felix Meyer-Wolters", "maintainer_email": "felix@meyerwolters.de", "name": "aioexec", "package_url": "https://pypi.org/project/aioexec/", "platform": "", "project_url": "https://pypi.org/project/aioexec/", "project_urls": { "Download": "https://github.com/feluxe/aioexec/tarball/0.4.0", "Homepage": "https://github.com/feluxe/aioexec" }, "release_url": "https://pypi.org/project/aioexec/0.4.0/", "requires_dist": null, "requires_python": "", "summary": "", "version": "0.4.0" }, "last_serial": 5502176, "releases": { "0.3.0": [ { "comment_text": "", "digests": { "md5": "5c6ec1ef903bd737fa329b951c03d937", "sha256": "d3caeeea6729d1a4979e4046baaaf3992344a887291a714fa74bda6783e798f6" }, "downloads": -1, "filename": "aioexec-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5c6ec1ef903bd737fa329b951c03d937", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 3938, "upload_time": "2018-03-27T05:31:48", "url": "https://files.pythonhosted.org/packages/31/1b/6171910dc6eb78553d9d23a37da4b1c47d810ebbb2c9a9e7a192a3128c16/aioexec-0.3.0-py3-none-any.whl" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "988e37e70b8c74f75ed70dcc31e00d81", "sha256": "124b26c54d204b862f488fd5389f7cbd5a7036da361fc1f0066d8f9eac23c4a1" }, "downloads": -1, "filename": "aioexec-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "988e37e70b8c74f75ed70dcc31e00d81", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4022, "upload_time": "2018-03-28T04:06:49", "url": "https://files.pythonhosted.org/packages/dc/73/d389bab0a64b7825220c61462d74b4342409f9d78fb672d589382e1035c8/aioexec-0.3.1-py3-none-any.whl" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "47b983326c38f2425a9e342fcba97a7b", "sha256": "5817d889247be649e0636054349b98a17762ff005bf9d657b407a6033e04c967" }, "downloads": -1, "filename": "aioexec-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "47b983326c38f2425a9e342fcba97a7b", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4024, "upload_time": "2018-03-28T04:16:39", "url": "https://files.pythonhosted.org/packages/3a/55/20b851abf8fb37272d02eed24e700a8564aa0b7e98cc622d77ea74a72653/aioexec-0.3.2-py3-none-any.whl" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "07f85d60cbd46dc3da8fec247079a49a", "sha256": "4dd9bb62865d3b038892217e56c38065f1d256e4afd760bedfab10a43e039172" }, "downloads": -1, "filename": "aioexec-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "07f85d60cbd46dc3da8fec247079a49a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7192, "upload_time": "2019-07-08T17:10:41", "url": "https://files.pythonhosted.org/packages/50/9f/c8f09b5d65e7224b98d7dd78ed03a08c1f450c2ea013a860db02bc2c88b6/aioexec-0.4.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "07f85d60cbd46dc3da8fec247079a49a", "sha256": "4dd9bb62865d3b038892217e56c38065f1d256e4afd760bedfab10a43e039172" }, "downloads": -1, "filename": "aioexec-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "07f85d60cbd46dc3da8fec247079a49a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7192, "upload_time": "2019-07-08T17:10:41", "url": "https://files.pythonhosted.org/packages/50/9f/c8f09b5d65e7224b98d7dd78ed03a08c1f450c2ea013a860db02bc2c88b6/aioexec-0.4.0-py3-none-any.whl" } ] }