{"id":28911890,"url":"https://github.com/monomonedula/timelooper","last_synced_at":"2025-07-05T12:36:46.682Z","repository":{"id":57475573,"uuid":"450938531","full_name":"monomonedula/timelooper","owner":"monomonedula","description":"Timed loops made simple","archived":false,"fork":false,"pushed_at":"2022-02-01T22:08:35.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T05:51:16.596Z","etag":null,"topics":["asyncio","loop","looping","python","timer","utility"],"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/monomonedula.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":"2022-01-22T21:21:32.000Z","updated_at":"2022-03-29T20:48:38.000Z","dependencies_parsed_at":"2022-09-07T13:51:22.103Z","dependency_job_id":null,"html_url":"https://github.com/monomonedula/timelooper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/monomonedula/timelooper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monomonedula%2Ftimelooper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monomonedula%2Ftimelooper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monomonedula%2Ftimelooper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monomonedula%2Ftimelooper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monomonedula","download_url":"https://codeload.github.com/monomonedula/timelooper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monomonedula%2Ftimelooper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261179155,"owners_count":23120861,"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","loop","looping","python","timer","utility"],"created_at":"2025-06-21T19:10:32.616Z","updated_at":"2025-07-05T12:36:46.675Z","avatar_url":"https://github.com/monomonedula.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Timelooper\n\n[![Build Status](https://app.travis-ci.com/monomonedula/timelooper.svg?branch=master)](https://app.travis-ci.com/monomonedula/timelooper)\n\nI found myself re-implementing the same \npattern over and over \nwhen it comes to repeating some task until \nsome condition is met OR \nthe time is up, so here it is abstracted and generalized into\na neat package. \n\nYep, that's 25 lines of code + tests.\n\n\nHere's a demo use case:\n```python\nfrom timelooper import Looped, loop_timed\nfrom datetime import timedelta\n\n# Suppose we are listening to some queue\n#   and want to batch the incoming messages.\n#   However, we only want to wait for\n#   some limited time for a batch \n#   to be formed.\n\n\nclass CollectableBatch(Looped):\n    def __init__(self, queue, maxsize):\n        self.batch = []\n        self._queue = queue\n        self._maxsize = maxsize\n    \n    async def do(self) -\u003e None:\n        self.batch.append(await self._queue.get())\n\n    def should_stop(self) -\u003e bool:\n        return len(self.batch) == self._maxsize\n\n    \ncollected = CollectableBatch(queue, maxsize=10)\nawait loop_timed(collected, timedelta(seconds=30))  \n\nprint(collected.batch)  # or whatever\n\n```\n\n\n### Installation\n```shell\npip install timelooper\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonomonedula%2Ftimelooper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonomonedula%2Ftimelooper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonomonedula%2Ftimelooper/lists"}