{ "info": { "author": "Roman Akopov", "author_email": "adontz@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "Broomio\n=======\n\nHistory\n-------\n\nWhy one more async library? Broomio started as an experiment. This code meant to be thrown away. I was inspired by curio and trio libraries, code looked so clean and easy to understand. That was brave new Python, no callbacks, low maintenance. Curio is the first challenger, questioning existing standard library choices; and Trio is the place where real science happens. Also authors of both libraries are really friendly, thank you `David Beazley `_ and `Nathaniel J. Smith `_! However, I was curios what are Python asyncio limits? Can asyncio based network server written in beautiful clean manner be as performant as raw epoll based with ugly spagetti callbacks? It turns out the answer is yes, but not without some tradeoffs.\n\nGetting Started\n---------------\n\nInstallation\n\"\"\"\"\"\"\"\"\"\"\"\"\n\nBroomio can be installed with pip.\n\n::\n\n pip3 install broomio\n\nUsage\n\"\"\"\"\"\"\"\"\"\"\"\"\n\nFirst of all, you'll need a loop. Loops are common concept in async libraries. Broomio provides no default loop, so loop should be created and started explicitly.\n\n::\n\n from broomio import Loop\n\n loop = Loop()\n loop.run()\n\nHowever this loop has nothing to do and will exit immediately. Lets add some coroutine and execute it a few times. Read more about coroutines in `PEP 0492 `_.\n\n::\n\n from broomio import Loop\n from broomio import sleep\n from time import time\n\n async def test(index):\n print(f'{index} started at {time()}')\n await sleep(2)\n print(f'{index} stopped at {time()}')\n\n\n loop = Loop()\n loop.start_soon(test(1))\n loop.start_soon(test(2))\n loop.start_soon(test(3))\n loop.run()\n\n\nYou will see output like the following\n\n::\n\n 3 started at 1456789015.0144565\n 2 started at 1456789015.0147984\n 1 started at 1456789015.0149508\n 3 stopped at 1456789017.0166693\n 2 stopped at 1456789017.0171447\n 1 stopped at 1456789017.0180902\n\n\nThe first thing to notice is that some functions which pause or block execution, like sleep, should be called with await. Skipping await will lead to all kinds of unexpected bad consequences. So be careful.\nThe second thing to notice is that coroutines behave more or less like threads. Please, find bellow equivalent code with threads.\n\n::\n\n from threading import Thread\n from time import sleep\n from time import time\n\n def test(index):\n print(f'{index} started at {time()}')\n sleep(2)\n print(f'{index} stopped at {time()}')\n\n t1 = Thread(target=lambda: child(1))\n t2 = Thread(target=lambda: child(2))\n t3 = Thread(target=lambda: child(3))\n\n t1.start()\n t2.start()\n t3.start()\n t1.join()\n t2.join()\n t3.join()\n\nOutput will be similar\n\n::\n\n 1 started at 1456789015.0149508\n 3 started at 1456789015.0144565\n 2 started at 1456789015.0147984\n 1 stopped at 1456789017.0180902\n 2 stopped at 1456789017.0171447\n 3 stopped at 1456789017.0166693\n\nDifference is that coroutines actually work in context of single thread. There are no operating system level threads or anything similar, it's pure user code solution. Kernel is not aware of coroutines.\n\nFind more examples in `corresponding folder `_ in source code.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/triflesoft/broomio", "keywords": "", "license": "LGPL", "maintainer": "", "maintainer_email": "", "name": "broomio", "package_url": "https://pypi.org/project/broomio/", "platform": "", "project_url": "https://pypi.org/project/broomio/", "project_urls": { "Homepage": "https://github.com/triflesoft/broomio" }, "release_url": "https://pypi.org/project/broomio/0.5.190510/", "requires_dist": null, "requires_python": "", "summary": "Fast AsyncIO Library", "version": "0.5.190510" }, "last_serial": 5291952, "releases": { "0.5.190510": [ { "comment_text": "", "digests": { "md5": "c7ff1f2b05b5cfbbd36e7fa1d8735774", "sha256": "00c3ca04aa1d8fcf2fc9969f844341af212c230b44279558a2c554f5234dec08" }, "downloads": -1, "filename": "broomio-0.5.190510-py3-none-any.whl", "has_sig": false, "md5_digest": "c7ff1f2b05b5cfbbd36e7fa1d8735774", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 22961, "upload_time": "2019-05-20T12:00:28", "url": "https://files.pythonhosted.org/packages/d7/80/fd6220913fac895211488f60e03839bcdc2d2ba47dc4131757bd14b70d44/broomio-0.5.190510-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c7ff1f2b05b5cfbbd36e7fa1d8735774", "sha256": "00c3ca04aa1d8fcf2fc9969f844341af212c230b44279558a2c554f5234dec08" }, "downloads": -1, "filename": "broomio-0.5.190510-py3-none-any.whl", "has_sig": false, "md5_digest": "c7ff1f2b05b5cfbbd36e7fa1d8735774", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 22961, "upload_time": "2019-05-20T12:00:28", "url": "https://files.pythonhosted.org/packages/d7/80/fd6220913fac895211488f60e03839bcdc2d2ba47dc4131757bd14b70d44/broomio-0.5.190510-py3-none-any.whl" } ] }