https://github.com/socketry/timers
Pure Ruby timers collections suitable for use with event loops
https://github.com/socketry/timers
Keywords from Contributors
rubygems activerecord mvc activejob rack multithreading background-jobs crash-reporting jobs sidekiq
Last synced: about 21 hours ago
JSON representation
Repository metadata
Pure Ruby timers collections suitable for use with event loops
- Host: GitHub
- URL: https://github.com/socketry/timers
- Owner: socketry
- License: mit
- Created: 2012-07-12T06:14:38.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2025-02-07T21:39:14.000Z (about 1 year ago)
- Last Synced: 2026-02-24T08:28:46.929Z (7 days ago)
- Language: Ruby
- Homepage:
- Size: 243 KB
- Stars: 340
- Watchers: 13
- Forks: 33
- Open Issues: 1
- Releases: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
readme.md
Timers
Collections of one-shot and periodic timers, intended for use with event loops such as async.
Installation
Add this line to your application's Gemfile:
gem 'timers'
And then execute:
$ bundle
Or install it yourself as:
$ gem install timers
Usage
Create a new timer group with Timers::Group.new:
require 'timers'
timers = Timers::Group.new
Schedule a proc to run after 5 seconds with Timers::Group#after:
five_second_timer = timers.after(5) { puts "Take five" }
The five_second_timer variable is now bound to a Timers::Timer object. To
cancel a timer, use Timers::Timer#cancel
Once you've scheduled a timer, you can wait until the next timer fires with Timers::Group#wait:
# Waits 5 seconds
timers.wait
# The script will now print "Take five"
You can schedule a block to run periodically with Timers::Group#every:
every_five_seconds = timers.every(5) { puts "Another 5 seconds" }
loop { timers.wait }
You can also schedule a block to run immediately and periodically with Timers::Group#now_and_every:
now_and_every_five_seconds = timers.now_and_every(5) { puts "Now and in another 5 seconds" }
loop { timers.wait }
If you'd like another method to do the waiting for you, e.g. Kernel.select,
you can use Timers::Group#wait_interval to obtain the amount of time to wait. When
a timeout is encountered, you can fire all pending timers with Timers::Group#fire:
loop do
interval = timers.wait_interval
ready_readers, ready_writers = select readers, writers, nil, interval
if ready_readers || ready_writers
# Handle IO
...
else
# Timeout!
timers.fire
end
end
You can also pause and continue individual timers, or all timers:
paused_timer = timers.every(5) { puts "I was paused" }
paused_timer.pause
10.times { timers.wait } # will not fire paused timer
paused_timer.resume
10.times { timers.wait } # will fire timer
timers.pause
10.times { timers.wait } # will not fire any timers
timers.resume
10.times { timers.wait } # will fire all timers
Contributing
We welcome contributions to this project.
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature). - Commit your changes (
git commit -am 'Add some feature'). - Push to the branch (
git push origin my-new-feature). - Create new Pull Request.
Developer Certificate of Origin
In order to protect users of this project, we require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.
Community Guidelines
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
Owner metadata
- Name: Socketry
- Login: socketry
- Email: contact@socketry.io
- Kind: organization
- Description: Modern asynchronous and timeout-capable I/O for Ruby.
- Website: https://socketry.io
- Location:
- Twitter: ioquatix
- Company:
- Icon url: https://avatars.githubusercontent.com/u/22138037?v=4
- Repositories: 149
- Last ynced at: 2025-10-21T07:56:11.543Z
- Profile URL: https://github.com/socketry
GitHub Events
Total
- Delete event: 1
- Pull request event: 4
- Fork event: 1
- Issues event: 1
- Watch event: 3
- Issue comment event: 6
- Push event: 4
- Pull request review event: 3
- Pull request review comment event: 1
- Create event: 1
Last Year
- Issues event: 1
- Watch event: 1
- Issue comment event: 1
Committers metadata
Last synced: 2 days ago
Total Commits: 245
Total Committers: 32
Avg Commits per committer: 7.656
Development Distribution Score (DDS): 0.62
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Samuel Williams | s****s@o****z | 93 |
| Tony Arcieri | b****e@g****m | 77 |
| Wander Hillen | w****n@g****m | 10 |
| Donovan Keme | de@f****k | 6 |
| Donovan Keme | c****e@e****l | 6 |
| Jeremy Hinegardner | j****y@c****g | 6 |
| Sean Gregory | s****s@p****t | 5 |
| Utenmiki | u****i@g****m | 4 |
| Chuck Remes | g****t@c****m | 4 |
| Tommy Ong Gia Phu | t****p@g****m | 3 |
| Utenmiki | t****3@g****m | 3 |
| Olle Jonsson | o****n@g****m | 3 |
| Ron Evans | r****s@g****m | 3 |
| Larry Lv | l****0@g****m | 2 |
| Lin Jen-Shin | g****t@g****g | 2 |
| Ryunosuke Sato | t****s@g****m | 2 |
| Yoshiki Takagi | y****g@g****m | 1 |
| Will Jessop | w****l@w****t | 1 |
| Vít Ondruch | v****h@r****m | 1 |
| Tim Smith | t****h@c****o | 1 |
| Feram | f****m@f****o | 1 |
| Ryan LeCompte | l****e@g****m | 1 |
| Peter Goldstein | p****n@g****m | 1 |
| Patrik Wenger | p****r@g****m | 1 |
| Nicholas Evans | n****s@4****m | 1 |
| Mike Bourgeous | m****s | 1 |
| Lavir the Whiolet | L****t@g****m | 1 |
| Klaus Trainer | k****r@p****e | 1 |
| Jesse Cooke | j****e@j****m | 1 |
| Dimitrij Denissenko | d****o@b****m | 1 |
| and 2 more... | ||
Committer domains:
- enten-itc.ch: 1
- blacksquaremedia.com: 1
- jc00ke.com: 1
- posteo.de: 1
- 410labs.com: 1
- feram.co: 1
- chef.io: 1
- redhat.com: 1
- willj.net: 1
- godfat.org: 1
- chuckremes.com: 1
- pigadmirersclub.net: 1
- copiousfreetime.org: 1
- extremist.digital: 1
- freed.network: 1
- oriontransfer.co.nz: 1
Issue and Pull Request metadata
Last synced: 2 months ago
Total issues: 28
Total pull requests: 61
Average time to close issues: 9 months
Average time to close pull requests: 2 months
Total issue authors: 25
Total pull request authors: 33
Average comments per issue: 5.61
Average comments per pull request: 3.79
Merged pull request: 50
Bot issues: 0
Bot pull requests: 2
Past year issues: 1
Past year pull requests: 4
Past year average time to close issues: N/A
Past year average time to close pull requests: 3 months
Past year issue authors: 1
Past year pull request authors: 2
Past year average comments per issue: 0.0
Past year average comments per pull request: 1.0
Past year merged pull request: 2
Past year bot issues: 0
Past year bot pull requests: 2
Top Issue Authors
- ioquatix (3)
- digitalextremist (2)
- jmwright (1)
- cpfarher (1)
- thesamesam (1)
- PikachuEXE (1)
- dsisnero (1)
- WJWH (1)
- ReubenM (1)
- jonbramble (1)
- jimmycuadra (1)
- brandsr (1)
- HoneyryderChuck (1)
- funny-falcon (1)
- dblock (1)
Top Pull Request Authors
- ioquatix (11)
- tarcieri (5)
- taki (5)
- nevans (3)
- chuckremes (3)
- olleolleolle (3)
- WJWH (2)
- dependabot[bot] (2)
- paddor (2)
- larrylv (2)
- fciballero (2)
- copiousfreetime (1)
- Atul9 (1)
- brunoenten (1)
- ghost (1)
Top Issue Labels
- bug (1)
- question (1)
Top Pull Request Labels
- dependencies (2)
- enhancement (1)
Package metadata
- Total packages: 3
-
Total downloads:
- rubygems: 394,951,074 total
- Total docker downloads: 2,213,364,790
- Total dependent packages: 70 (may contain duplicates)
- Total dependent repositories: 56,335 (may contain duplicates)
- Total versions: 80
- Total maintainers: 2
gem.coop: timers
Pure Ruby one-shot and periodic timers.
- Homepage: https://github.com/socketry/timers
- Documentation: http://www.rubydoc.info/gems/timers/
- Licenses: MIT
- Latest release: 4.4.0 (published about 1 year ago)
- Last Synced: 2026-03-01T14:02:02.414Z (2 days ago)
- Versions: 28
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 197,469,491 Total
- Docker Downloads: 1,106,682,395
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.05%
- Docker downloads count: 0.078%
- Downloads: 0.121%
- Maintainers (2)
rubygems.org: timers
Pure Ruby one-shot and periodic timers.
- Homepage: https://github.com/socketry/timers
- Documentation: http://www.rubydoc.info/gems/timers/
- Licenses: MIT
- Latest release: 4.4.0 (published about 1 year ago)
- Last Synced: 2026-03-02T09:33:02.314Z (1 day ago)
- Versions: 28
- Dependent Packages: 70
- Dependent Repositories: 56,335
- Downloads: 197,481,583 Total
- Docker Downloads: 1,106,682,395
-
Rankings:
- Downloads: 0.096%
- Docker downloads count: 0.103%
- Dependent repos count: 0.147%
- Dependent packages count: 0.413%
- Average: 1.43%
- Stargazers count: 3.104%
- Forks count: 4.72%
- Maintainers (2)
proxy.golang.org: github.com/socketry/timers
- Homepage:
- Documentation: https://pkg.go.dev/github.com/socketry/timers#section-documentation
- Licenses: mit
- Latest release: v4.4.0+incompatible (published about 1 year ago)
- Last Synced: 2026-03-02T12:32:57.822Z (about 21 hours ago)
- Versions: 24
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 3.053%
- Forks count: 4.26%
- Average: 6.913%
- Dependent packages count: 9.56%
- Dependent repos count: 10.779%
Dependencies
- benchmark-ips >= 0 development
- ruby-prof >= 0 development
- bake-bundler >= 0
- bake-modernize >= 0
- bundler >= 0 development
- covered >= 0 development
- rspec ~> 3.0 development
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
Score: 30.97961098390365