<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/lib/timeout.rb, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/timeout] Bump up 0.4.1</title>
<updated>2023-11-07T04:56:40+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2023-11-07T04:44:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=acf0f8551e6acc4f14143433e798c5cfb9087144'/>
<id>acf0f8551e6acc4f14143433e798c5cfb9087144</id>
<content type='text'>
https://github.com/ruby/timeout/commit/a65e49cc31
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/timeout/commit/a65e49cc31
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Bump up v0.4.0</title>
<updated>2023-06-23T03:52:03+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2023-06-23T03:51:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b7375770ef15c7d7b3fdf14bf1964a0209881f98'/>
<id>b7375770ef15c7d7b3fdf14bf1964a0209881f98</id>
<content type='text'>
https://github.com/ruby/timeout/commit/413194f8d2
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/timeout/commit/413194f8d2
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Raise exception instead of throw/catch for timeouts</title>
<updated>2023-06-22T18:24:46+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2023-06-22T18:24:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e8c9385123d6f7678b8c37f5543933703907abd2'/>
<id>e8c9385123d6f7678b8c37f5543933703907abd2</id>
<content type='text'>
(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 =&gt; 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 &lt;nobu@ruby-lang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
(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 =&gt; 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 &lt;nobu@ruby-lang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] bump up 0.3.2</title>
<updated>2023-02-16T00:57:08+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2023-02-16T00:49:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=65b6411e9db31591ae2a4928acaa0bc2cc03c427'/>
<id>65b6411e9db31591ae2a4928acaa0bc2cc03c427</id>
<content type='text'>
https://github.com/ruby/timeout/commit/e1b2448101
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/timeout/commit/e1b2448101
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Don't move the timer_thread when it's enclosed</title>
<updated>2023-02-15T19:25:05+00:00</updated>
<author>
<name>Rick Blommers</name>
<email>rick@blommersit.nl</email>
</author>
<published>2023-02-12T14:23:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=610375edfc2ed487dc5798278a5923154aec1c1f'/>
<id>610375edfc2ed487dc5798278a5923154aec1c1f</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Bump version to 0.3.1</title>
<updated>2022-12-05T08:13:18+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2022-12-05T08:12:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3909cfaa02f96976e2734948e356001345c133be'/>
<id>3909cfaa02f96976e2734948e356001345c133be</id>
<content type='text'>
https://github.com/ruby/timeout/commit/4941e8c871
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/timeout/commit/4941e8c871
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Explicit add the timeout thread to default ThreadGroup</title>
<updated>2022-09-27T16:59:35+00:00</updated>
<author>
<name>Lars Kanis</name>
<email>lars@greiz-reinsdorf.de</email>
</author>
<published>2022-09-25T09:14:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9d56d9975d867c94ab2a6d76e4482112ab6c3319'/>
<id>9d56d9975d867c94ab2a6d76e4482112ab6c3319</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Give a name to the background thread</title>
<updated>2022-07-13T12:16:15+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2022-07-13T11:48:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8290d76647f8db9df6d18c654d723b14cf0b3507'/>
<id>8290d76647f8db9df6d18c654d723b14cf0b3507</id>
<content type='text'>
https://github.com/ruby/timeout/commit/5594ae2f4d
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/timeout/commit/5594ae2f4d
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Keep a private reference to `Process.clock_gettime`</title>
<updated>2022-06-09T09:58:49+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2022-06-08T13:44:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4e21b19a61aadd785df1d731d79265fef16fb7c8'/>
<id>4e21b19a61aadd785df1d731d79265fef16fb7c8</id>
<content type='text'>
`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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/timeout] Set the flag surely before return</title>
<updated>2022-05-25T10:50:47+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-05-25T10:50:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cd6f87eefc35922d21a1889e038c9f50f229004f'/>
<id>cd6f87eefc35922d21a1889e038c9f50f229004f</id>
<content type='text'>
https://github.com/ruby/timeout/commit/f3a31abdfb
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/timeout/commit/f3a31abdfb
</pre>
</div>
</content>
</entry>
</feed>
