From: samuel@oriontransfer•net
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50675] [Ruby trunk Bug#595] Fiber ignores ensure clause
Date: Thu, 22 Nov 2018 00:38:50 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-75026.20181122003849.0847f0c4f8c6cea1@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-595.20080924192809@ruby-lang.org
Issue #595 has been updated by ioquatix (Samuel Williams).
In a GC language, it's impossible to ensure this, unless you want the GC to invoke some functionality.
I suggest adding something like `Fiber#stop` which causes internally `Fiber#resume` to raise exception.
It should be up to user code to deal with this IMHO, e.g.
```
fib = Fiber.new{
begin
Fiber.yield :ok
ensure
puts "should be print out"
end
}
begin
p fib.resume
ensure
fib.stop
end
```
I believe there is no logical solution to avoid this issue except making it explicit of consumer of fiber. It's the same reason why we should do the following:
```
f = File.open
begin
f.write "..."
ensure
f.close
end
```
----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-75026
* Author: ko1 (Koichi Sasada)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version:
* ruby -v: -
* Backport:
----------------------------------------
Ruby プロセス終了時,Fiber が ensure を無視します.
これは,前から直そうと思って手がついていなかった問題です.
10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
```
fib = Fiber.new{
begin
Fiber.yield :ok
ensure
puts "should be print out"
end
}
p fib.resume
```
---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2018-11-22 0:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-595.20080924192809@ruby-lang.org>
2011-06-11 5:52 ` [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause Koichi Sasada
2011-06-11 13:14 ` [ruby-dev:43744] " Yukihiro Matsumoto
2011-06-11 13:23 ` [ruby-dev:43745] " Yui NARUSE
2011-06-26 14:24 ` [ruby-dev:43951] " Hiroshi Nakamura
2012-03-13 6:06 ` [ruby-dev:45354] [ruby-trunk - Bug #595][Assigned] " Yui NARUSE
2012-07-25 10:08 ` [ruby-dev:46005] [ruby-trunk - Bug #595] " ko1 (Koichi Sasada)
2012-07-25 13:24 ` [ruby-dev:46006] " naruse (Yui NARUSE)
2012-08-05 4:05 ` [ruby-dev:46030] " wanabe (_ wanabe)
2012-08-05 10:18 ` [ruby-dev:46031] " KOSAKI Motohiro
2012-08-20 8:56 ` [ruby-dev:46060] " SASADA Koichi
2014-01-13 10:59 ` [ruby-dev:47883] " Yura, Sokolov
2015-10-12 13:16 ` [ruby-dev:49299] [Ruby trunk " eregontp
2017-01-31 7:22 ` [ruby-dev:49967] [Ruby trunk Bug#595] " ko1
2018-11-22 0:38 ` samuel [this message]
2018-12-20 1:15 ` [ruby-dev:50722] " samuel
2018-12-20 4:19 ` [ruby-dev:50723] " samuel
2019-01-14 7:32 ` [ruby-dev:50763] " naruse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-75026.20181122003849.0847f0c4f8c6cea1@ruby-lang.org \
--to=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).