0.0
No commit activity in last 3 years
No release in over 3 years
A simple implementation of timeout
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0
>= 0
 Project Readme

Simple Timeout

A simple implementation of Timeout.

The standard Timeout::timeout will always wait until the block finishes execution, and then, when the thread where the block is being executed can't be killed for some reason, your whole program get blocked. SimpleTimeout::timeout lets you choose if you want to wait for the block to finish execution or not. By default it won't wait.

Build Status Code Climate Test Coverage Gem Version

Usage

Basic usage:

SimpleTimeout::Timeout(5) do
  # Some code that should not take more than 5 seconds
end

Options

SimpleTimeout::timeout receives 4 parameters:

def self.timeout(seconds,timeout_error_class=SimpleTimeout::Error,wait_for_block=false,&block)
  # the implementation ...
end
  • seconds: How much seconds to wait before raise timeout_error_class.
  • timeout_error_class: The error to raise in case of timeout.
  • wait_for_block: This one is the main reason for me to implement this gem. The standard Timeout::timeout will always wait until the block finishes execution, and then, when the thread where the block is been executed can't be killed for some reason, your whole program get blocked. SimpleTimeout::timeout lets you choose if you want to wait for the block to finish execution or not. By default it won't wait.
  • block: The block to execute.

Installation

Add this line to your application’s Gemfile:

gem 'simple_timeout'

And then execute:

bundle

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: