{"id":15713504,"url":"https://github.com/apainintheneck/time-limit","last_synced_at":"2025-07-06T16:36:27.287Z","repository":{"id":235008561,"uuid":"789901924","full_name":"apainintheneck/time-limit","owner":"apainintheneck","description":"Spawn fibers with execution time limits in Crystal","archived":false,"fork":false,"pushed_at":"2024-06-01T19:31:04.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T18:46:25.532Z","etag":null,"topics":["crystal","library","timeout"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/apainintheneck.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-21T21:19:45.000Z","updated_at":"2024-04-27T08:07:31.000Z","dependencies_parsed_at":"2024-10-24T10:51:05.980Z","dependency_job_id":"97ff67d3-2a20-4313-818e-85b0183d3c2a","html_url":"https://github.com/apainintheneck/time-limit","commit_stats":null,"previous_names":["apainintheneck/time-limit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/apainintheneck/time-limit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apainintheneck%2Ftime-limit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apainintheneck%2Ftime-limit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apainintheneck%2Ftime-limit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apainintheneck%2Ftime-limit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apainintheneck","download_url":"https://codeload.github.com/apainintheneck/time-limit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apainintheneck%2Ftime-limit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263936495,"owners_count":23532541,"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":["crystal","library","timeout"],"created_at":"2024-10-03T21:31:50.191Z","updated_at":"2025-07-06T16:36:27.237Z","avatar_url":"https://github.com/apainintheneck.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# time-limit\n\nA simple helper to allow you to run logic in a fiber with a time limit. All return values and exceptions are propogated from the spawned fiber back to the original fiber.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     time-limit:\n       github: apainintheneck/time-limit\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"time-limit\"\n\n# When the calculation completes in the time limit,\n# the return value from the block is returned.\nresult = TimeLimit.spawn(5.seconds) do\n  5 * 5 * 5 * 5 * 5\nend\n\nputs result # =\u003e 3125\n\n# When the calculation raises an error,\n# it gets re-raised.\nbegin\n  TimeLimit.spawn(5.seconds) do\n    raise ArgumentError.new\n  end\nrescue ex\n  puts ex.class # =\u003e ArgumentError\nend\n\n# When the calculation goes beyond the time limit,\n# a timeout exception is raised.\nbegin\n  TimeLimit.spawn(5.seconds) do\n    sleep 10.seconds\n  end\nrescue ex\n  puts ex.class # =\u003e TimeLimit::TimeoutException\nend\n```\n\nSee the specs for more examples.\n\n## Development\n\n`crystal spec` is used for testing and `crystal tool format` is used for linting.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/your-github-user/time-limit/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [apainintheneck](https://github.com/apainintheneck) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapainintheneck%2Ftime-limit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapainintheneck%2Ftime-limit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapainintheneck%2Ftime-limit/lists"}