
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
SafePoller is a Ruby gem that provides a safe and reliable way to perform periodic polling operations in multi-threaded environments. It offers a simple and intuitive API for running a block of code at a defined interval, while ensuring thread safety and preventing potential race conditions. SafePoller allows developers to focus on implementing their logic without worrying about thread safety issues.
Install the gem and add to the application's Gemfile by executing:
$ bundle add safe_poller
Or add the following line to the application's Gemfile:
gem 'safe_poller', github: 'nejdetkadir/safe_poller', branch: 'main'
If bundler is not being used to manage dependencies, install the gem by executing:
gem install safe_poller
To use SafePoller, simply call the SafePoller.poll
method, passing in a block of code to be executed at the specified interval:
poller = SafePoller.poll(interval: 2.0) do
# Code to be executed at 2-second intervals
end
By default, the interval is set to 1 second. You can also specify the duration of the poll by using the SafePoller.poll_for
method:
poller = SafePoller.poll_for(30, interval: 2.0) do
# Code to be executed every 2 seconds for 30 seconds
end
Or, you can specify the end time of the poll using the SafePoller.poll_until
method:
end_time = Time.now + 60
poller = SafePoller.poll_until(end_time, interval: 2.0) do
# Code to be executed every 2 seconds until 1 minute from now
end
You can pause and resume the poller using the pause
and resume
methods, respectively:
poller.pause # Pauses the poller
poller.resume # Resumes the poller
You can check if the poller is currently running or paused using the running?
and paused?
methods, respectively:
poller.running? # Returns true if the poller is running, false otherwise
poller.paused? # Returns true if the poller is paused, false otherwise
You can stop the poller using the stop
method:
poller.stop # Stops the poller
Bug reports and pull requests are welcome on GitHub at https://github.com/nejdetkadir/safe_poller. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the SafePoller project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that safe_poller demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.