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=-4.1 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY shortcircuit=no autolearn=ham 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 47DED1F4B4 for ; Fri, 11 Dec 2020 10:35:39 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B7094120BF1; Fri, 11 Dec 2020 19:34:48 +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 C0E54120ACA for ; Fri, 11 Dec 2020 19:34:45 +0900 (JST) Received: by filterdrecv-p3las1-685fdc5bbc-pv2l8 with SMTP id filterdrecv-p3las1-685fdc5bbc-pv2l8-21-5FD34B6B-1E 2020-12-11 10:35:23.705937027 +0000 UTC m=+41591.409895765 Received: from herokuapp.com (unknown) by ismtpd0022p1iad2.sendgrid.net (SG) with ESMTP id 2zPJaPygSI2NXlFkim3WZQ for ; Fri, 11 Dec 2020 10:35:23.505 +0000 (UTC) Date: Fri, 11 Dec 2020 10:35:23 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 77284 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17363 X-Redmine-Issue-Author: marcandre X-Redmine-Sender: nobu 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?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4BzhiyT1RQfsMr1sXn61ji?= =?us-ascii?Q?GfkPNlZo7B=2FP=2FBTeUMlNLnycXy2hmQCDeyLetMk?= =?us-ascii?Q?+BXt5zyUGjLvLHXBtGBtD84o6MW6FpbH9+Dmzf9?= =?us-ascii?Q?RmqYUoDkcOgZjaw+2NWbxVT7ujPTRyuVoe8mu0n?= =?us-ascii?Q?YOm858TeEgckeZFirve1oi08Hejo6NoLLugVOWF?= =?us-ascii?Q?8GMOttMGgp9uwHz5Y=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 101416 Subject: [ruby-core:101416] [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 nobu (Nobuyoshi Nakada). It is just one line to built-in `Timeout::Error`. ```c rb_define_class_under(rb_define_module("Timeout"), "Error", rb_eRuntimeError); ``` ---------------------------------------- Feature #17363: Timeouts https://bugs.ruby-lang.org/issues/17363#change-89177 * 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/