From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 1BB6D1F44D for ; Sun, 7 Apr 2024 12:48:20 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=XRsCHXYA; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=ZCt/1th2; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 6052981429; Sun, 7 Apr 2024 12:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1712494090; bh=Jpc2ixCK2lcRcn3v3BYVqUZrePrdG/6mN/D5sOrWB1U=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=XRsCHXYAXbM2ZCve9d88S5fxn1OkxIXM/j4LFo93Lh7p4giXAdpIFiQXL9HVL+KbL hBVvYR3vE+on5umf7oDhHGtIWwL5x2WKAbKbWoqvbakDPAP7NLSiyuomm1y3hitJt+ wyBwtOPV9BKCK03EHD1tsWKMTvrRJtWXjfXPr4gE= Received: from s.wrqvtvvn.outbound-mail.sendgrid.net (s.wrqvtvvn.outbound-mail.sendgrid.net [149.72.120.130]) by nue.mailmanlists.eu (Postfix) with ESMTPS id AF80D81424 for ; Sun, 7 Apr 2024 12:48:07 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=ZCt/1th2; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=Es9hPXSkSJCa7XGTbwpzzZ+BoymeqqtVt/iDdfyd4ys=; b=ZCt/1th2GOdzujUe8Db1dd88gxKZLBJvLo0CDXwML3o9jl6327+926O9f4LPIMUu7QEL cEy3YAui7fa5n0EqPwb2MG3/y1QXE0dhlnH5cQ+vfj4xdO5cJcQvWDYVYbnqreHNbGsCJy yWErzk/lX5w2N2iUM55DsH+LAgfQnvBR+agUIikA52qlvoUMsfnOVcB5x2ndSE2Gtuenh6 YsTFVEIip82cr+2ORmNK305iJi6egpSSddKT+MB83MDv46endJcDOZd67k0n1hsPF688K+ Me/ci9qfeXuEDiZPc/msyRpIRLmWjQ3fAVvMjUip/fGlWEoQwO+ZDf1xTffRyFpA== Received: by recvd-d64b65bdd-qpx95 with SMTP id recvd-d64b65bdd-qpx95-1-66129606-5 2024-04-07 12:48:06.539136291 +0000 UTC m=+225453.427599188 Received: from herokuapp.com (unknown) by geopod-ismtpd-11 (SG) with ESMTP id 5Wd_iwvnR56P02EhslZYmw for ; Sun, 07 Apr 2024 12:48:06.511 +0000 (UTC) Date: Sun, 07 Apr 2024 12:48:06 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20413 X-Redmine-Issue-Author: ioquatix X-Redmine-Issue-Assignee: ioquatix X-Redmine-Issue-Priority: Normal X-Redmine-Sender: ioquatix 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-Redmine-MailingListIntegration-Message-Ids: 94051 X-SG-EID: =?us-ascii?Q?u001=2E3QFJPY5gaRwyNXkncYONHM3OeFnb=2FgeOrLDgg3PYIKrq5rvk81iAipQ1q?= =?us-ascii?Q?cdmuT9o5PIWGjXtTDstodNmslT=2F6xfCuIofWR2K?= =?us-ascii?Q?w8msDgVaVLy0IAEw53wwGk1MulL5hpGsVxyGsQ2?= =?us-ascii?Q?qilx9s602bpdg7ILrhDfxpmxBvns7z=2FKatCrz+p?= =?us-ascii?Q?TB3Q7=2FF=2Flnf+fVLjcATPLVZ45KmseFvq2cqn9Rn?= =?us-ascii?Q?gt38gwVDDZJJkhkldWqdZ+ZtN7b2hf6U1=2FeUPhV?= =?us-ascii?Q?qyCV+BNQDUNOYXofaUw6Wu=2Faxw=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: QRA5YT74D5NV5724V2RMDPGD5PPZCDYC X-Message-ID-Hash: QRA5YT74D5NV5724V2RMDPGD5PPZCDYC X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117456] [Ruby master Bug#20413] Enumerator can block fiber scheduler. List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "ioquatix (Samuel Williams) via ruby-core" Cc: "ioquatix (Samuel Williams)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20413 has been updated by ioquatix (Samuel Williams). After discussing it with Eregon on Slack, he withdrew his objection to this change. In general, this change: - Aligns `Fiber.new` with `rb_fiber_new` so that they both produce non-blocking fibers. - Doesn't affect existing code, as there is no obvious usage of `rb_fiber_new` by GitHub code search (small/zero blast radius). - Only impacts usage within the fiber scheduler, i.e. no effect outside of fiber scheduler beside the predicate value itself. - Even within the fiber scheduler, it is transparent to user code. ---------------------------------------- Bug #20413: Enumerator can block fiber scheduler. https://bugs.ruby-lang.org/issues/20413#change-107841 * Author: ioquatix (Samuel Williams) * Status: Closed * Assignee: ioquatix (Samuel Williams) * Backport: 3.0: UNKNOWN, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- Using `Enumerator` in the event loop can cause problems as the fiber created by `rb_fiber_new` is blocking by default. It should be non-blocking. ```ruby #!/usr/bin/env ruby require 'async' Async do Async do while true puts "Hello" sleep 1 end end enumerator = Enumerator.new do |yielder| while true yielder << "World" sleep 1 end end while true puts enumerator.next end end ``` Before this PR, the output is: ``` > ./test.rb Hello World World World World World World ... ``` After this PR, the output is: ``` > ./test.rb Hello World Hello World Hello World Hello World Hello World ... ``` The reason why this happens, is because the enumerator `sleep` never yields to the event loop. See for the fix. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/