{ "info": { "author": "J\u00fcrgen Knauth", "author_email": "pubsrc@binary-overflow.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License" ], "description": "jk_asyncio_syncasync\n==========\n\nIntroduction\n------------\n\nThis python module enables asyncio based functions/methods to invoke classic synchroneous functions/methods. This is implemented by delegating execution of to a thread pool.\n\nInformation about this module can be found here:\n\n* [github.org](https://github.com/jkpubsrc/....)\n* [pypi.python.org](https://pypi.python.org/pypi/jk_asyncio_syncasync)\n\nWhy this module?\n----------------\n\nMixing synchroneous and asynchroneous code is not so easy and generally not recommended. Unfortunately sometimes you run into a situation where you can't avoid mixing both. For example this is the case if you need to invoke a synchroneous method implemented in a third party module where there is no asynchroneous counterpart implementation to the synchroneous one so that you can't avoid invoking the synchroneous code. In such a situation your call to a synchroneous function/method would block the asynchroneous task loop.\n\nThis module solves this problem by running the synchroneous method in a background thread without block the asynchroneous task loop. It therefore provides a safe way to invoke synchroneous code from within asynchroneous code.\n\nLimitations of this module\n--------------------------\n\nThis module focuses on `asyncio` (and `asyncio`) only. For `trio` this module is not required as `trio` already contains this functionality.\n\nHow to install module\n----------------------\n\nThis module can be installed easily using `pip`.\n\nUse this command for a system wide installation of this module:\n\n```bash\n$ sudo pip install jk-asyncio-syncasync\n```\n\nUse this command for user specific installation of this module:\n\n```bash\n$ pip install --user jk-asyncio-syncasync\n```\n\nThe PiPy module is always kept in sync with the Github repository so using PyPi is equivalent to a manual installation using the code provided on Github.\n\nHow to use this module\n----------------------\n\n### Import this module\n\nPlease include this module into your application using the following code:\n\n```python\nfrom jk_asyncio_syncasync import *\n```\n\n### Invoke a synchroneous function directly\n\nLet's asume we have implemented a synchroneous function, for example this one:\n\n```python\ndef synchroneousFunction():\n\tprint(\"Beginning synchroneous task ...\")\n\ttime.sleep(2)\n\tprint(\"Synchroneous task completed.\")\n```\n\nLet's now asume we want to invoke this function. This can be done with the following code using the function `call_sync()` provided by this module:\n\n```python\nawait call_sync(synchroneousFunction)\n```\n\n### Invoke a synchroneous function using a decorator\n\nLet's asume we have implemented a synchroneous function, for example this one:\n\n```python\ndef synchroneousFunction():\n\tprint(\"Beginning synchroneous task ...\")\n\ttime.sleep(2)\n\tprint(\"Synchroneous task completed.\")\n```\n\nYou can make use of a decorator in order to make this function asynchroneous:\n\n```python\n@make_async\ndef synchroneousFunction():\n\tprint(\"Beginning synchroneous task ...\")\n\ttime.sleep(2)\n\tprint(\"Synchroneous task completed.\")\n```\n\nNow invoking this function is easy:\n\n```python\nawait synchroneousFunction()\n```\n\n### Invoking methods\n\nIt's perfectly safe to use `call_sync()` and the decorator `@make_async` with methods. Example:\n\nContact Information\n-------------------\n\nThis is Open Source code. That not only gives you the possibility of freely using this code it also\nallows you to contribute. Feel free to contact the author(s) of this software listed below, either\nfor comments, collaboration requests, suggestions for improvement or reporting bugs:\n\n* J\u00fcrgen Knauth: jknauth@uni-goettingen.de, pubsrc@binary-overflow.de\n\nLicense\n-------\n\nThis software is provided under the following license:\n\n* Apache Software License 2.0", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/jkpubsrc/ython-module-jk-asyncio-syncasync/tarball/0.2019.10.19", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jkpubsrc/ython-module-jk-asyncio-syncasync", "keywords": "asyncio", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "jk-asyncio-syncasync", "package_url": "https://pypi.org/project/jk-asyncio-syncasync/", "platform": "", "project_url": "https://pypi.org/project/jk-asyncio-syncasync/", "project_urls": { "Download": "https://github.com/jkpubsrc/ython-module-jk-asyncio-syncasync/tarball/0.2019.10.19", "Homepage": "https://github.com/jkpubsrc/ython-module-jk-asyncio-syncasync" }, "release_url": "https://pypi.org/project/jk-asyncio-syncasync/0.2019.10.19/", "requires_dist": null, "requires_python": "", "summary": "This python module enables asyncio based functions/methods to invoke classic synchroneous functions/methods. This is implemented by delegating execution of to a thread pool.", "version": "0.2019.10.19" }, "last_serial": 5999272, "releases": { "0.2019.10.19": [ { "comment_text": "", "digests": { "md5": "1158e47bacc00a34f3ee0f0b4d9c1d43", "sha256": "41f83ff523dd58f3f3490f9acf3b2dd26d641c579c80b0ecc1b38d8dcc1dc74b" }, "downloads": -1, "filename": "jk_asyncio_syncasync-0.2019.10.19.tar.gz", "has_sig": false, "md5_digest": "1158e47bacc00a34f3ee0f0b4d9c1d43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7171, "upload_time": "2019-10-19T09:10:58", "url": "https://files.pythonhosted.org/packages/c6/42/cb9abf30c6e1207b4520c6f7f7e787a5be3d715bc18b0be6c13afff837c6/jk_asyncio_syncasync-0.2019.10.19.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1158e47bacc00a34f3ee0f0b4d9c1d43", "sha256": "41f83ff523dd58f3f3490f9acf3b2dd26d641c579c80b0ecc1b38d8dcc1dc74b" }, "downloads": -1, "filename": "jk_asyncio_syncasync-0.2019.10.19.tar.gz", "has_sig": false, "md5_digest": "1158e47bacc00a34f3ee0f0b4d9c1d43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7171, "upload_time": "2019-10-19T09:10:58", "url": "https://files.pythonhosted.org/packages/c6/42/cb9abf30c6e1207b4520c6f7f7e787a5be3d715bc18b0be6c13afff837c6/jk_asyncio_syncasync-0.2019.10.19.tar.gz" } ] }