{"id":18918046,"url":"https://github.com/piccolo-orm/asyncio_tools","last_synced_at":"2025-04-15T09:32:19.635Z","repository":{"id":57412215,"uuid":"242819004","full_name":"piccolo-orm/asyncio_tools","owner":"piccolo-orm","description":"Useful utilities for working with asyncio - including an asyncio.gather wrapper.","archived":false,"fork":false,"pushed_at":"2022-12-26T23:06:09.000Z","size":24,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T19:44:43.559Z","etag":null,"topics":["asyncio","concurrency","gather","hacktoberfest","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piccolo-orm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-24T19:04:57.000Z","updated_at":"2023-12-19T03:08:24.000Z","dependencies_parsed_at":"2023-01-31T02:15:48.527Z","dependency_job_id":null,"html_url":"https://github.com/piccolo-orm/asyncio_tools","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piccolo-orm%2Fasyncio_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piccolo-orm%2Fasyncio_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piccolo-orm%2Fasyncio_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piccolo-orm%2Fasyncio_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piccolo-orm","download_url":"https://codeload.github.com/piccolo-orm/asyncio_tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933350,"owners_count":21185461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","concurrency","gather","hacktoberfest","python"],"created_at":"2024-11-08T10:29:25.154Z","updated_at":"2025-04-15T09:32:19.283Z","avatar_url":"https://github.com/piccolo-orm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asyncio_tools\n\nUseful utilities for working with asyncio.\n\n## Installation\n\n```\npip install asyncio-tools\n```\n\n## gather\n\nProvides a convenient wrapper around `asyncio.gather`.\n\n```python\nfrom asyncio_tools import gather, CompoundException\n\n\nasync def good():\n    return 'OK'\n\n\nasync def bad():\n    raise ValueError()\n\n\nasync def main():\n    response = await gather(\n        good(),\n        bad(),\n        good()\n    )\n\n    # Check if a particular exception was raised.\n    ValueError in response.exception_types\n    # \u003e\u003e\u003e True\n\n    # To get all exceptions:\n    print(response.exceptions)\n    # \u003e\u003e\u003e [ValueError()]\n\n    # To get all instances of a particular exception:\n    response.exceptions_of_type(ValueError)\n    # \u003e\u003e\u003e [ValueError()]\n\n    # To get the number of exceptions:\n    print(response.exception_count)\n    # \u003e\u003e\u003e 1\n\n    # You can still access all of the results:\n    print(response.all)\n    # \u003e\u003e\u003e ['OK', ValueError(), 'OK']\n\n    # And can access all successes (i.e. non-exceptions):\n    print(response.successes)\n    # \u003e\u003e\u003e ['OK', 'OK']\n\n    # To get the number of successes:\n    print(response.success_count)\n    # \u003e\u003e\u003e 2\n\n    try:\n        # To combines all of the exceptions into a single one, which merges the\n        # messages.\n        raise response.compound_exception()\n    except CompoundException as compound_exception:\n        print(\"Caught it\")\n\n        if ValueError in compound_exception.exception_types:\n            print(\"Caught a ValueError\")\n\n```\n\nRead some background on why `gather` is useful:\n\n- https://www.piccolo-orm.com/blog/exception-handling-in-asyncio/\n- https://www.piccolo-orm.com/blog/asyncio-gather/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiccolo-orm%2Fasyncio_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiccolo-orm%2Fasyncio_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiccolo-orm%2Fasyncio_tools/lists"}