summaryrefslogtreecommitdiff
path: root/lib/timeout.rb
AgeCommit message (Collapse)Author
2024-12-16[ruby/timeout] Bump up v0.4.3Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/607d8c6fbe
2024-12-03[ruby/timeout] removed the non numeric checkCosmic Oppai
https://github.com/ruby/timeout/commit/7d2af46a00 Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2024-12-03[ruby/timeout] updated doc stringCosmic Oppai
https://github.com/ruby/timeout/commit/4be6423de4 Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2024-12-03[ruby/timeout] updated doc and kept the nil compatiabilityCosmicOppai
https://github.com/ruby/timeout/commit/f992632cf3
2024-12-03[ruby/timeout] refactor the change to raise for nil and type-errror and ↵CosmicOppai
added tests https://github.com/ruby/timeout/commit/ffc8d7c003
2024-12-03[ruby/timeout] refactor the change to keep the compatability with nil and ↵CosmicOppai
type-errror and added tests https://github.com/ruby/timeout/commit/8342544979
2024-12-03[ruby/timeout] added the check for negative secCosmicOppai
https://github.com/ruby/timeout/commit/8e57887eee
2024-11-06[ruby/timeout] Bump up v0.4.2Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/2f52522994
2024-08-28[ruby/timeout] timeout.rb: Update documentationOlle Jonsson
This is a followup to #49. https://github.com/ruby/timeout/commit/683fdb45ee
2023-12-25[ruby/timeout] [DOC] Missing documentsNobuyoshi Nakada
https://github.com/ruby/timeout/commit/301ad4cfdc
2023-11-07[ruby/timeout] Bump up 0.4.1Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/a65e49cc31
2023-06-23[ruby/timeout] Bump up v0.4.0Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/413194f8d2
2023-06-22[ruby/timeout] Raise exception instead of throw/catch for timeoutsJeremy Evans
(https://github.com/ruby/timeout/pull/30) throw/catch is used for non-local control flow, not for exceptional situations. For exceptional situations, raise should be used instead. A timeout is an exceptional situation, so it should use raise, not throw/catch. Timeout's implementation that uses throw/catch internally causes serious problems. Consider the following code: ```ruby def handle_exceptions yield rescue Exception => exc handle_error # e.g. ROLLBACK for databases raise ensure handle_exit unless exc # e.g. COMMIT for databases end Timeout.timeout(1) do handle_exceptions do do_something end end ``` This kind of design ensures that all exceptions are handled as errors, and ensures that all exits (normal exit, early return, throw/catch) are not handled as errors. With Timeout's throw/catch implementation, this type of code does not work, since a timeout triggers the normal exit path. See https://github.com/rails/rails/pull/29333 for an example of the damage Timeout's design has caused the Rails ecosystem. This switches Timeout.timeout to use raise/rescue internally. It adds a Timeout::ExitException subclass of exception for the internal raise/rescue, which Timeout.timeout will convert to Timeout::Error for backwards compatibility. Timeout::Error remains a subclass of RuntimeError. This is how timeout used to work in Ruby 2.0. It was changed in Ruby 2.1, after discussion in [Bug #8730] (commit https://github.com/ruby/timeout/commit/238c003c921e in the timeout repository). I think the change from using raise/rescue to using throw/catch has caused significant harm to the Ruby ecosystem at large, and reverting it is the most sensible choice. From the translation of [Bug #8730], it appears the issue was that someone could rescue Exception and not reraise the exception, causing timeout errors to be swallowed. However, such code is broken anyway. Using throw/catch causes far worse problems, because then it becomes impossible to differentiate between normal control flow and exceptional control flow. Also related to this is [Bug #11344], which changed how Thread.handle_interrupt interacted with Timeout. https://github.com/ruby/timeout/commit/f16545abe6 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-02-16[ruby/timeout] bump up 0.3.2Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/e1b2448101
2023-02-15[ruby/timeout] Don't move the timer_thread when it's enclosedRick Blommers
Don't move the timer_thread to ThreadGroup::Default, when it's created in an enclosed ThreadGroup. Prevents the exception: "add" can't move from the enclosed thread group" https://github.com/ruby/timeout/commit/eb889d2c8b
2022-12-05[ruby/timeout] Bump version to 0.3.1Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/4941e8c871
2022-09-28[ruby/timeout] Explicit add the timeout thread to default ThreadGroupLars Kanis
Otherwise the timeout thread would be added to the ThreadGroup of the thread that makes the first call to Timeout.timeout . Fixes bug 19020: https://bugs.ruby-lang.org/issues/19020 Add a test case to make sure the common thread doesn't leak to another ThreadGroup https://github.com/ruby/timeout/commit/c4f1385c9a
2022-07-13[ruby/timeout] Give a name to the background threadJean Boussier
https://github.com/ruby/timeout/commit/5594ae2f4d
2022-06-09[ruby/timeout] Keep a private reference to `Process.clock_gettime`Jean Boussier
`timeout 0.3.0` broke our test suite because we have some tests that stubs `Process.clock_gettime` making it return a value in the past, causing `Timeout` to trigger almost immediately. I beleive it wasn't a problem before because it was relying on `Process.sleep`. https://github.com/ruby/timeout/commit/e5911a303e
2022-05-25[ruby/timeout] Set the flag surely before returnNobuyoshi Nakada
https://github.com/ruby/timeout/commit/f3a31abdfb
2022-05-25[ruby/timeout] Hack to avoid leak checkerNobuyoshi Nakada
https://github.com/ruby/timeout/commit/9a9b03b44c
2022-05-25[ruby/timeout] Bump version to 0.3.0Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/f69f954a94
2022-05-19[ruby/timeout] Remove redundant done? checkBenoit Daloze
* It's already checked inside #interrupt. https://github.com/ruby/timeout/commit/5f43254f81
2022-05-19[ruby/timeout] Synchronize all accesses to @doneBenoit Daloze
* So it is trivially correct. * Performance seems the same overall. https://github.com/ruby/timeout/commit/5e0d8e1637
2022-05-19[ruby/timeout] Handle Timeout + fork and add test for itBenoit Daloze
https://github.com/ruby/timeout/commit/4baee63b9b
2022-05-19[ruby/timeout] Reimplement Timeout.timeout with a single thread and a QueueBenoit Daloze
https://github.com/ruby/timeout/commit/2bafc458f1
2021-10-14[ruby/timeout] Bump up timeout version to 0.2.0Hiroshi SHIBATA
https://github.com/ruby/timeout/commit/02e792ddd8
2021-09-27[ruby/timeout] Freeze VERSIONrm155
https://github.com/ruby/timeout/commit/ac7b010c41
2021-05-06[ruby/timeout] Only run timeout_after hook on fiber scheduler if scheduler ↵Jeremy Evans
exists https://github.com/ruby/timeout/commit/4893cde0ed
2021-05-06[ruby/timeout] Avoid unnecessary object allocationJeremy Evans
Idea from nobu. https://github.com/ruby/timeout/commit/aecdaa23b3
2021-05-06[ruby/timeout] Make Timeout::Error#exception with multiple arguments not ↵Jeremy Evans
ignore arguments This makes: raise(Timeout::Error.new("hello"), "world") raise a TimeoutError instance with "world" as the message instead of "hello", for consistency with other Ruby exception classes. This required some internal changes to keep the tests passing. Fixes [Bug #17812] https://github.com/ruby/timeout/commit/952154dbf9
2021-03-30Fix handling of timeout accessing scheduler outside of non-blocking context.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Update method name and add documentation.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Update lib/timeout.rbSamuel Williams
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Add hook for `Timeout.timeout`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-01-03[ruby/timeout] Removed deprecated names that had been warned for 5 yearsNobuyoshi Nakada
https://github.com/ruby/timeout/commit/f9a9758a41
2020-12-22Update library versions of the default gems.Hiroshi SHIBATA
They are followed up with https://github.com/ruby/ruby/commit/8fb02b7a97317090e3946e6f2d4a7d034f9699f1
2020-07-30Extract version number from the sourceNobuyoshi Nakada
"requiring version.rb" strategy has some issues. - cannot work when cross-compiling - often introduces wrong namespace - must know the superclasses - costs at each runtime than at build-time etc. Notes: Merged: https://github.com/ruby/ruby/pull/3375
2019-06-04Add some documentation to Timeout#timeout about possible issuesJeremy Evans
Documentation requested in [Bug #15886].
2017-12-12Add uplevel keyword to Kernel#warn and use itshyouhei
If uplevel keyword is given, the warning message is prepended with caller file and line information and the string "warning: ". The use of the uplevel keyword makes Kernel#warn format output similar to how rb_warn formats output. This patch modifies net/ftp and net/imap to use Kernel#warn instead of $stderr.puts or $stderr.printf, since they are used for printing warnings. This makes lib/cgi/core and tempfile use $stderr.puts instead of warn for debug logging, since they are used for debug printing and not for warning. This does not modify bundler, rubygems, or rdoc, as those are maintained outside of ruby and probably wish to remain backwards compatible with older ruby versions. rb_warn_m code is originally from nobu, but I've changed it so that it only includes the path and lineno from uplevel (not the method), and also prepends the string "warning: ", to make it more similar to rb_warn. From: Jeremy Evans code@jeremyevans.net Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17Fix typo in `Timeout` doc [ci skip]kazu
Author: yuuji.yaginuma <yuuji.yaginuma@gmail.com> https://github.com/ruby/ruby/pull/1760 [Fix GH-1760] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07fix a typo [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07timeout.rb: custom error messagenobu
* lib/timeout.rb (Timeout#timeout): add custom error message argument. [Feature #11650] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18timeout.rb: watcher thread namenobu
* lib/timeout.rb (Timeout#timeout): set watcher thread name to caller location for debugging. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-13timeout.rb: freeze a string messagenobu
* lib/timeout.rb (Timeout#timeout): freeze a string message to reduce string allocations. [Fix GH-996] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-30variable.c: Module#deprecate_constantnobu
* variable.c (rb_const_get_0): warn deprecated constant reference. * variable.c (rb_mod_deprecate_constant): mark constants to be warned as deprecated. [Feature #11398] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14timeout.rb: suppress a warningnobu
* lib/timeout.rb (Timeout): get rid of an argument prefix warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-13timeout.rb: warn deprecated methodnobu
* lib/timeout.rb (timeout): warn as deprecated for a long time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-13timeout.rb: internal constantsnobu
* lib/timeout.rb (Timeout): make internal constants private. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
close