{"id":22243833,"url":"https://github.com/dgkim5360/asyncloop","last_synced_at":"2025-07-28T01:33:14.329Z","repository":{"id":57412222,"uuid":"107881787","full_name":"dgkim5360/asyncloop","owner":"dgkim5360","description":"A Celery-like event loop with asyncio and no dependencies","archived":false,"fork":false,"pushed_at":"2018-07-10T13:42:17.000Z","size":252,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-20T02:48:57.950Z","etag":null,"topics":["coroutines","eventloop","python-asyncio","python3"],"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/dgkim5360.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-10-22T16:11:41.000Z","updated_at":"2018-07-11T00:43:14.000Z","dependencies_parsed_at":"2022-09-26T17:11:12.234Z","dependency_job_id":null,"html_url":"https://github.com/dgkim5360/asyncloop","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dgkim5360/asyncloop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkim5360%2Fasyncloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkim5360%2Fasyncloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkim5360%2Fasyncloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkim5360%2Fasyncloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgkim5360","download_url":"https://codeload.github.com/dgkim5360/asyncloop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkim5360%2Fasyncloop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267451079,"owners_count":24089293,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["coroutines","eventloop","python-asyncio","python3"],"created_at":"2024-12-03T04:29:32.112Z","updated_at":"2025-07-28T01:33:13.973Z","avatar_url":"https://github.com/dgkim5360.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asyncloop\n\n[![Build Status](https://travis-ci.org/dgkim5360/asyncloop.svg?branch=master)](https://travis-ci.org/dgkim5360/asyncloop)\n\n*A Celery-like event loop with `asyncio` and no dependencies*\n\nIt runs an `asyncio` event loop in a separate daemon thread, drives native coroutines within the event loop, and then returns the future in an asynchronous manner.\n\n### Example\n\nThis example sends 6000 simple HTTP GET requests with a job queue of size 30. The `monitor` method shows the process, which may be just an eye candy.\n\n* The first column shows (id of future, state of the future), the finished jobs.\n* The second column shows (id of future, state of the corresponding coroutine), the running jobs.\n* The last column shows the number of pending jobs.\n\nTo serve the HTTP GET responses, the Nginx docker image is used.\n\n\u003cimg src=\"https://cdn.rawgit.com/dgkim5360/asyncloop/1cd1da79/examples/example-aiohttp-get.svg\"\u003e\n\n```shell\n$ docker run --name ANY_NAME \\\n    -v /path/to/asyncloop/examples/nginx-staticfiles:/usr/share/nginx/html:ro \\\n    -d \\\n    -p 8080:80 \\\n    nginx\n(venv) $ pip install aiohttp\n(venv) $ python examples/aiohttp-get.py\n```\n\nPlease note that the `monitor` method does not run in Windows OS, since it uses the `curses` module, which is available only in UNIX-like OS.\n\n### Dependency\n\nIt requires Python 3.5+.\n\n### Installation\n\n```shell\n$ git clone https://github.com/dgkim5360/asyncloop.git\n$ cd asyncloop\nasyncloop$ python setup.py install\n```\n\n### Getting started\n\n```python\nimport asyncio as aio\n\nfrom asyncloop import AsyncLoop\n\n\n# A simple job, which should be a native coroutine\nasync def job_to_wait(sleep_sec):\n    await aio.sleep(sleep_sec)\n    return sleep_sec\n\n\n# A simple callback\ndef callback(fut):\n    if fut.cancelled():\n        print('CANCELLED:', fut)\n    elif fut.done():\n        print('DONE:', fut)\n\tprint('RESULT:', fut.result()\n\n\n# AsyncLoop starts\naloop = AsyncLoop(maxsize=5)\naloop.start()\n\n# Submit a job and be free to work on\n# it returns an concurrent.futures.Future object\nfut = aloop.submit(job_to_wait(10), callback)\n\n# The job immediately goes to the running queue,\n# which is a simple dictionary with capacity.\naloop.running\n# {\n#     \u003cFuture at 0x####\u003e: \u003ccoroutine object job_to_wait\u003e\n# }\n\n# After 10 seconds the callback activated\n# DONE: \u003cFuture at 0x#### state=finished returned int\u003e\n# RESULT: 10\n\n# Let's check the running queue again.\n# Now the running queue (aloop.running) is empty!\naloop.running\n# {}\n\n# We can also confirm that the job is finished as\n# the AsyncLoop instance contains the future object of finished jobs.\naloop.done\n# {\u003cFuture at 0x#### state=finished returned int\u003e}\n\n# Get a result\nassert fut.result() == 10\n\n# Submit more jobs\naloop.submit_many((job_to_wait(5) for _ in range(10)))\n\n# AsyncLoop only runs 5 jobs and other jobs are pending\nassert aloop.running.qsize() == 5\nassert aloop.pending.qsize() == 5\n\n# After 5 seconds so that 5 jobs done,\n# 5 pending jobs automatically start so that\n# they move into the running queue.\nassert len(aloop.done) == 6\nassert aloop.running.qsize() == 5\nassert aloop.pending.qsize() == 0\n\n# Check the last results after 10 seconds so that all jobs done.\nassert len(aloop.done) == 11\nassert aloop.running.qsize() == 0\nassert aloop.pending.qsize() == 0\n```\n\nSo far, that's all.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgkim5360%2Fasyncloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgkim5360%2Fasyncloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgkim5360%2Fasyncloop/lists"}