From: "Eregon (Benoit Daloze)" Date: 2022-07-22T09:56:39+00:00 Subject: [ruby-core:109300] [Ruby master Bug#18810] Make `Kernel#p` interruptable. Issue #18810 has been updated by Eregon (Benoit Daloze). mame (Yusuke Endoh) wrote in #note-2: > Since `Kernel#p` is a method for debugging, I think this spec would be useful. If it is made interruptable, it will be difficult to use `Kernel#p` in a block of `Thread.handle_interrupt(TimeoutError => :on_blocking)`. You mean if `p` is used inside a `Timeout.timeout` block? And you'd worry the object would be printed but no newline, or the write would be interrupted in the middle and have written some partial output (is that even possible when writing to a terminal given write is atomic in at least that case?)? If it's about the newline, that would be solved by `p` appending "\n" to the string and only doing a single write, everything is a million times simpler that way. I think this is a very rare case and any developer must expect this or far worse effects of asynchronous exceptions when using `Timeout.timeout`/`Thread#raise`. > We discussed this issue at the dev meeting. We will add a document to Kernel#p so that it is uninterruptible and for debugging purpose. IMHO this should not be part of specification, but an implementation choice/detail. So I'd suggest to write it like "Kernel#p is uninterruptible on CRuby to avoid being interrupted by Timeout.timeout" or so in the docs. ---------------------------------------- Bug #18810: Make `Kernel#p` interruptable. https://bugs.ruby-lang.org/issues/18810#change-98437 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- While figuring out https://bugs.ruby-lang.org/issues/18465 I found a test which fails when `rb_io_flush` becomes blocking.: https://github.com/ruby/ruby/commit/fe6b2e20e9f17ed2c2900aa72994e075ffdc7124 It seems unusual to me that `Kernel#p` is uninterruptible (unique among all Ruby methods). I'd like to make `Kernel#p` interruptible. -- https://bugs.ruby-lang.org/ Unsubscribe: