{ "info": { "author": "Mark Vartanyan", "author_email": "kolypto@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "[![Build Status](https://api.travis-ci.org/kolypto/py-asynctools.png?branch=master)](https://travis-ci.org/kolypto/py-asynctools)\n[![Pythons](https://img.shields.io/badge/python-2.7%20%7C%203.4%E2%80%933.7%20%7C%20pypy-blue.svg)](.travis.yml)\n\n\nAsyncTools\n==========\n\nAsync Tools for Python.\n\nTable of Contents\n=================\n\n* Threading\n * Async\n * Parallel\n * Pool \n\nThreading\n=========\n\nThreading is the most simple thing, but because of [GIL](https://wiki.python.org/moin/GlobalInterpreterLock) it's useless for computation.\nOnly use when you want to parallelize the access to a blocking resource, e.g. network.\n\nAsync\n-----\n\nSource: [asynctools/threading/Async.py](asynctools/threading/Async.py)\n\nDecorator for functions that should be run in a separate thread.\nWhen the function is called, it returns a [`threading.Event`](https://docs.python.org/2/library/threading.html#event-objects).\n\n```python\nfrom asynctools.threading import Async\n\n@Async\ndef request(url):\n # ... do request\n\nrequest('http://example.com') # Async request\nrequest('http://example.com').wait() # wait for it to complete\n```\n\nIf you want to wait for multiple threads to complete, see next chapters.\n\n\nParallel\n--------\n\nSource: [asynctools/threading/Parallel.py](asynctools/threading/Parallel.py)\n\nExecute functions in parallel and collect results.\nEach function is executed in its own thread, all threads exit immediately.\n\nMethods:\n\n* `__call__(*args, **kwargs)`: Add a job. Call the `Parallel` object so it calls the worker function with the same arguments\n* `map(jobs)`: Convenience method to call the worker for every argument\n* `first(timeout=None)`: Wait for a single result to be available, with an optional timeout in seconds. The result is returned as soon as it's ready.\n If all threads fail with an error -- `None` is returned.\n* `join()`: Wait for all tasks to be finished, and return two lists:\n\n * A list of results\n * A list of exceptions\n\nExample:\n\n```python\nfrom asynctools.threading import Parallel\n\ndef request(url):\n # ... do request\n return data\n\n# Execute\npll = Parallel(request)\nfor url in links:\n pll(url) # Starts a new thread\n\n\n# Wait for the results\nresults, errors = pll.join()\n```\n\nSince the request method takes just one argument, this can be chained:\n\n```python\nresults, errors = Parallel(request).map(links).join()\n```\n\n\n\nPool\n----\n\nSource: [asynctools/threading/Pool.py](asynctools/threading/Pool.py)\n\nCreate a pool of threads and execute work in it.\nUseful if you do want to launch a limited number of long-living threads.\n\nMethods are same with [`Parallel`](#parallel), with some additions:\n\n* `__call__(*args, **kwargs)`\n* `map(jobs)`\n* `first(timeout=None)`\n* `close()`: Terminate all threads. The pool is no more usable when closed.\n* `__enter__`, `__exit__` context manager to be used with `with` statement\n\nExample:\n\n```python\nfrom asynctools.threading import Pool\n\ndef request(url):\n # ... do long request\n return data\n\n# Make pool\npool = Pool(request, 5)\n\n# Assign some job\nfor url in links:\n pll(url) # Runs in a pool\n\n# Wait for the results\nresults, errors = pll.join()\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kolypto/py-asynctools", "keywords": "async,threading,multiprocessing", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "asynctools", "package_url": "https://pypi.org/project/asynctools/", "platform": "any", "project_url": "https://pypi.org/project/asynctools/", "project_urls": { "Homepage": "https://github.com/kolypto/py-asynctools" }, "release_url": "https://pypi.org/project/asynctools/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Async tools for Python", "version": "0.1.3" }, "last_serial": 4680890, "releases": { "0.0.1-0": [ { "comment_text": "built for Linux-3.13.0-30-generic-x86_64-with-glibc2.4", "digests": { "md5": "20324c7003fc1152c6b1ba864a8f3ec8", "sha256": "435206a041a6eacadf1df5f2ca802b185af91812566716991551eae34a3fd9c7" }, "downloads": -1, "filename": "asynctools-0.0.1-0.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "20324c7003fc1152c6b1ba864a8f3ec8", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 5010, "upload_time": "2014-07-17T18:02:04", "url": "https://files.pythonhosted.org/packages/52/92/29b2cd71f2d8ef54ccd76b09e33479fdc29218bbe7b26de3a7eda09c3850/asynctools-0.0.1-0.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "f31ff872884278764ba7a9c62c6b2463", "sha256": "51dc99c7f2c291eba9ad1c9083e4d67488b5d55fa7733f71b17a209ef6705c05" }, "downloads": -1, "filename": "asynctools-0.0.1-0.tar.gz", "has_sig": false, "md5_digest": "f31ff872884278764ba7a9c62c6b2463", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4384, "upload_time": "2014-07-17T18:02:01", "url": "https://files.pythonhosted.org/packages/c8/ee/cdc10fd1c947220a89ac933f2b8ea0dd6df8cc442e2c8d1c7dc57791e12c/asynctools-0.0.1-0.tar.gz" } ], "0.1.0-0": [ { "comment_text": "built for Linux-3.13.0-30-generic-x86_64-with-glibc2.4", "digests": { "md5": "3e207fd504ceeabbfe69de615ae472ea", "sha256": "656ef4c3193a54f47e3b9a0705550b5d43de1d6570e950a6990c13efc57448d2" }, "downloads": -1, "filename": "asynctools-0.1.0-0.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "3e207fd504ceeabbfe69de615ae472ea", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 5445, "upload_time": "2014-07-18T14:25:26", "url": "https://files.pythonhosted.org/packages/58/5d/04f9b661b3a4f17f875760d7047bf70d1f7c29f99bd855cc435261577e37/asynctools-0.1.0-0.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "fcf178cc87a2e4b79027aafb116a67c2", "sha256": "a177e7fa1eaddb1266cdc9658db94e9d86c8fc0ccd68ab2a65b290c6c332fb3d" }, "downloads": -1, "filename": "asynctools-0.1.0-0.tar.gz", "has_sig": false, "md5_digest": "fcf178cc87a2e4b79027aafb116a67c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4845, "upload_time": "2014-07-18T14:25:23", "url": "https://files.pythonhosted.org/packages/5b/43/245e4bfae6b421f5ee70c6da99289cd586dcfdc7bddc48ea3d1fd6fc3801/asynctools-0.1.0-0.tar.gz" } ], "0.1.2-0": [ { "comment_text": "built for Linux-3.13.0-30-generic-x86_64-with-glibc2.4", "digests": { "md5": "16fd277140219294f0cdecb104b5b216", "sha256": "c285e8b23f8d8a2fb4cb488515f2bcfa52ce066b56b472d35b30a63d1810e232" }, "downloads": -1, "filename": "asynctools-0.1.2-0.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "16fd277140219294f0cdecb104b5b216", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 6798, "upload_time": "2014-07-18T16:22:01", "url": "https://files.pythonhosted.org/packages/60/b1/2036b8e237093bb22238dfcb5bf942955b366b4f989718a43c80787170b5/asynctools-0.1.2-0.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "c9fccec0d7fe02dc8602cbc30df2458f", "sha256": "91e9b6e6afec81fa7a2599a0e5fdefb8ebf6f4de9aba7ec5f4cb2917cceed252" }, "downloads": -1, "filename": "asynctools-0.1.2-0.tar.gz", "has_sig": false, "md5_digest": "c9fccec0d7fe02dc8602cbc30df2458f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6266, "upload_time": "2014-07-18T16:21:58", "url": "https://files.pythonhosted.org/packages/66/cc/056768a0334fba4e4881e5ae36e6e7551ed2cd516952ea7daafe0a22fc2f/asynctools-0.1.2-0.tar.gz" } ], "0.1.2-1": [ { "comment_text": "built for Linux-3.13.0-30-generic-x86_64-with-glibc2.4", "digests": { "md5": "4ede071547a803bdbe82a53da3b43c0d", "sha256": "5e370ddf376e7ac2865a2cc057f8c827ca0a171a6828867c4a84787a4e0db073" }, "downloads": -1, "filename": "asynctools-0.1.2-1.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "4ede071547a803bdbe82a53da3b43c0d", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 6387, "upload_time": "2014-07-18T17:10:16", "url": "https://files.pythonhosted.org/packages/58/cf/a3179d773ba18f310f24122871c3f27b7dfc0a1fcdc280f621060a59e271/asynctools-0.1.2-1.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "2e62e850043dee6838566721a9c11ad3", "sha256": "a780f8f699cc24ad73027603672b5759c3741b1cd0654f95b228bc1c3386889b" }, "downloads": -1, "filename": "asynctools-0.1.2-1.tar.gz", "has_sig": false, "md5_digest": "2e62e850043dee6838566721a9c11ad3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6306, "upload_time": "2014-07-18T17:10:13", "url": "https://files.pythonhosted.org/packages/a6/99/4540b3416ecdfb713871cbd5e1ae4728f026fb5bbfd4b9ed87f4233ae99e/asynctools-0.1.2-1.tar.gz" } ], "0.1.2-2": [ { "comment_text": "", "digests": { "md5": "965f3459dd87099f6811ae4690b475f4", "sha256": "20f487c3722c1da60e4e9a1b32f40e671cf620d4e2583215fe6a4ba46250bebc" }, "downloads": -1, "filename": "asynctools-0.1.2_2-py2-none-any.whl", "has_sig": false, "md5_digest": "965f3459dd87099f6811ae4690b475f4", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 7867, "upload_time": "2014-08-14T15:39:25", "url": "https://files.pythonhosted.org/packages/1f/90/413503caa6b7b8c1e3d57f0cd4b6c17b2d63a3b8c75dfe5994bd1a5523e7/asynctools-0.1.2_2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1187bbd6b16e0d8d5a0f4144e840b42b", "sha256": "c8f209d879e0292ed802735b0421bf918f50fad89a3cd9d24723d678fa36e49f" }, "downloads": -1, "filename": "asynctools-0.1.2-2.tar.gz", "has_sig": false, "md5_digest": "1187bbd6b16e0d8d5a0f4144e840b42b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6315, "upload_time": "2014-08-14T15:39:19", "url": "https://files.pythonhosted.org/packages/80/a9/ed943af8009c2c7b88fb27502230d32e76879b43023b87724155a9034aa1/asynctools-0.1.2-2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "78ef474965700b4f6f99f211efccaf71", "sha256": "1c457795cee369b23c6b53db536963cc9ae0e2a4b2a9bb1cc2e27f4f4929a83d" }, "downloads": -1, "filename": "asynctools-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "78ef474965700b4f6f99f211efccaf71", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6636, "upload_time": "2019-01-10T12:25:19", "url": "https://files.pythonhosted.org/packages/37/a8/2680bd7963d18390d7541909a83508e0b4d5c004359029d3d9cc730aeb0d/asynctools-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0093730d2c5685c621e045a8e9bfc527", "sha256": "77fffc74361a120d2e532fa4d5b7f7fbdc15a94edf3501cdc0402ec305e78de2" }, "downloads": -1, "filename": "asynctools-0.1.3.tar.gz", "has_sig": false, "md5_digest": "0093730d2c5685c621e045a8e9bfc527", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5968, "upload_time": "2019-01-10T12:25:22", "url": "https://files.pythonhosted.org/packages/ee/8a/6bc92af3b1cc02fac837ad7bf71448949d99fcd971ab42e8196aead3d2d0/asynctools-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "78ef474965700b4f6f99f211efccaf71", "sha256": "1c457795cee369b23c6b53db536963cc9ae0e2a4b2a9bb1cc2e27f4f4929a83d" }, "downloads": -1, "filename": "asynctools-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "78ef474965700b4f6f99f211efccaf71", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6636, "upload_time": "2019-01-10T12:25:19", "url": "https://files.pythonhosted.org/packages/37/a8/2680bd7963d18390d7541909a83508e0b4d5c004359029d3d9cc730aeb0d/asynctools-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0093730d2c5685c621e045a8e9bfc527", "sha256": "77fffc74361a120d2e532fa4d5b7f7fbdc15a94edf3501cdc0402ec305e78de2" }, "downloads": -1, "filename": "asynctools-0.1.3.tar.gz", "has_sig": false, "md5_digest": "0093730d2c5685c621e045a8e9bfc527", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5968, "upload_time": "2019-01-10T12:25:22", "url": "https://files.pythonhosted.org/packages/ee/8a/6bc92af3b1cc02fac837ad7bf71448949d99fcd971ab42e8196aead3d2d0/asynctools-0.1.3.tar.gz" } ] }