From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id D78FB1F4B4 for ; Thu, 10 Dec 2020 11:53:13 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 80EB9120C2D; Thu, 10 Dec 2020 20:52:27 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 499F8120BF9 for ; Thu, 10 Dec 2020 20:52:25 +0900 (JST) Received: by filterdrecv-p3iad2-6544fb89f6-vd5px with SMTP id filterdrecv-p3iad2-6544fb89f6-vd5px-19-5FD20C24-14 2020-12-10 11:53:08.196721558 +0000 UTC m=+571830.996273350 Received: from herokuapp.com (unknown) by ismtpd0066p1mdw1.sendgrid.net (SG) with ESMTP id Jac9qeR0TeqLHGBStYqf2A for ; Thu, 10 Dec 2020 11:53:08.123 +0000 (UTC) Date: Thu, 10 Dec 2020 11:53:08 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 77255 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17363 X-Redmine-Issue-Author: marcandre X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr0KX7fdpFqRrADQsS2ovG?= =?us-ascii?Q?dZrQG3D8AhxiH3VZFZApDYvFvQPVeFuShy1Kr6k?= =?us-ascii?Q?NCT23ikKhwEx5V5x9KAdw97jN8H=2FN8lyiCFJqkl?= =?us-ascii?Q?6YO7zsxL95c3+MuOLJY+gg3br=2FtAusTPQK=2FrtjL?= =?us-ascii?Q?eFr=2FP7d7usIcIXDmfGpui62Hbx4p2j3kQWhIR4C?= =?us-ascii?Q?7wLrugNi8WlkH6mxQ=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 101386 Subject: [ruby-core:101386] [Ruby master Feature#17363] Timeouts X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17363 has been updated by Eregon (Benoit Daloze). marcandre (Marc-Andre Lafortune) wrote in #note-8: > Good point. We could create `Thread::Timeout` as a common base class for all 3? `Thread::TimeoutError` then maybe? Sounds OK, but not sure timeouts are always related to threads (e.g., an IO#select timeout). Might not matter much, so `Thread::TimeoutError` is fine for me. ---------------------------------------- Feature #17363: Timeouts https://bugs.ruby-lang.org/issues/17363#change-89144 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal ---------------------------------------- Builtin methods like `Queue.pop` and `Ractor.receive` have no timeout parameter. We should either: - provide such a parameter - and/or provide a `Timeout::wake` that raises an timeout error only if the block is currently sleeping. Details: ```ruby q = Queue.new # ... elem = Timeout::timeout(42) { q.pop } # => It is possible that an element is retreived from the queue but never stored in `elem` elem = Timeout::wake(42) { q.pop } # => Guaranteed that either element is retrieved from the queue or an exception is raised, never both Timeout::wake(42) { loop {} } # => infinite loop # and/or elem = q.pop(timeout: 42) ``` Currently, the only reliable way to have a Queue that accepts a timeout is to re-implement it from scratch. This post describe how involved that can be: https://spin.atomicobject.com/2017/06/28/queue-pop-with-timeout-fixed/ -- https://bugs.ruby-lang.org/