Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129371 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 794BF1A00BD for ; Fri, 21 Nov 2025 14:38:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763735927; bh=opV59wNPe9DRpP0otQDeM1FWVrSMXslRc3vuZb39Kq0=; h=References:In-Reply-To:From:Date:Subject:To:From; b=M63kS5qiPiVEac5EuHkzhnG60arYt2+Bnp9Qfg+CbSJfxudjg+aB4w64PSLw2T4pa 2ZJGlBkdTxzpU+pxg2Bff3Fep4gZ96YtlVlCI3RweeushoFix/LOiCfAUzFj87POFt /4GyTLRSXmfcJR2tfdlhRnDuPuK/JjtPSSCCVhD1XlETLbD5oxSFu8hQd9qbiLQwvN RAW93CNY2KcxtAvfU5fdMJgg/5foRMNmkTZkeKb/l35eyIXWz+riJbCp0aU7TIaBp5 SM+DIIJoO6M+v9haRuPzMzOS3cD1/KoLSn8rDU3HhPWVdH0SrGEuwIa/2xan/PfM+f NhRSZKJ5UemIg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 80BBD1806B9 for ; Fri, 21 Nov 2025 14:38:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 21 Nov 2025 14:38:41 +0000 (UTC) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-b73a9592fb8so440736066b.1 for ; Fri, 21 Nov 2025 06:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=croquemonsieur-be.20230601.gappssmtp.com; s=20230601; t=1763735915; x=1764340715; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=opV59wNPe9DRpP0otQDeM1FWVrSMXslRc3vuZb39Kq0=; b=MV5rI5Ra7azYkDRVkfTZo2637wv7UlhVgbUeycImGqK0BRHiJ4iQ6oCLrwWNVHL5lx thLigWVyMBnPbI5wgtIE2w2DTzeB9oYs+F0EOISDFWV6X/3AyqO7b5S0g5bO70IUKscD 0AfUGPEr9eLAFN0MaX90i3/78quSQmAP7jymMJQ+UhYbgrQV22Hcf0QundAns3KQ76g/ 4/nMk43GqemceQaKHT7ih9fnBbBLaMi+HMtYxrsPsKhSzmPwh+8GyiWI38YQVcJ/rBgF Kn4r+pWdmphSi7KZPTOQaXuDfoh6eeHptRmSh5lTJHNEGPOhff/olZaRjEwxcgrgB93X ey2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763735915; x=1764340715; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=opV59wNPe9DRpP0otQDeM1FWVrSMXslRc3vuZb39Kq0=; b=OlAvmiuDDAf+PoW9+2onj/JIakAIaiTgWusmfsn6oEvWH2WTdJfksu10QNEFz3Kd6Z MF77ipDgQ5LzqYTGRcy+6twcBRu0JhoogLDsbGMIK0G0/E87c6U38ebxz57siAhblUem RajfVX+Es/jSWFFlWLu76cfpeEvN5CQYBkW5tMtK9iEpcDfyJVL3Lx0hao5jhpI7UWBp zyKeR1XIPPYG3KiXUmhh8dtEtTfMzPYWZhR9JNjS6jBGSVOg13ahHhk0MxxJmpnpGeSh K1pdd3vo3/j8jL9gRkdoYIF+KVy/raISjGuOmJQGeDn+ROJTIz2VYqfP+zizwAl4eboX a+HA== X-Forwarded-Encrypted: i=1; AJvYcCUUS2N94PYnQPtl25efTFVUciA1GonND8CTH4mRdMLp3aido/eG78gb6Q3sXJ0F8eBMDTEbT07T8QI=@lists.php.net X-Gm-Message-State: AOJu0YxeLPrHH5deyrwCidJeQu/nTHRZJfK1YOTarvUj+kICeiWr69aj 8iAOh8QV+gTujqMIlTPQvphRPsuaKyb5gzr/scOO1trbuR7Fvjvz0S2igIDePlX8SHBBkdCtbhs YBYEB6SFlEWEZ2wLPfATR2OQeP9gtDzpHs+5A8AKdoz1HpjadkxO+HV0= X-Gm-Gg: ASbGncuqhFkvzwRU55vD4XyOhq2aJPX1DofOWxfblfr9JVst/ow3grJCJWpZulSpK+j 3uNNfADXoqjzhxax3J0P256UlNQ4CrGBuNwb1/zlJTQN50IFukFxkoImHi+OAcLpGSyL/z6MhCb awvpibe3sQZy10HvBj+H57x/MWq8TkVTVENKjzwBcQiv5Stkn/b58ybXMUM6zILgauIer8PhIRX QBNhVtJOxmzv31uHhK8KnlcdtdWv3M+lFlq1sWTde7thI0J/HZ9UNG25zQseQXR6yP50/SdHo8J K8QnIIUwaP7W64QPTbb+yT3GCypgrp6PouFl4MA= X-Google-Smtp-Source: AGHT+IHHqGrtEoORy/pbwAgLgCDzRorWUIxe/xZG+cnVrEK+OfKqecP1inY1dsnP4hhzld63yQUmHQNc16Zrq1J6xl4= X-Received: by 2002:a17:907:d19:b0:b07:87f1:fc42 with SMTP id a640c23a62f3a-b766ef1d094mr356532566b.16.1763735915088; Fri, 21 Nov 2025 06:38:35 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 21 Nov 2025 15:38:22 +0100 X-Gm-Features: AWmQ_bnoBmwUeCaFp8t2ZcH8bd_u17WoFKScoM55lcTgVe_O0s6JZ1rjb0nWF2U Message-ID: Subject: Re: [PHP-DEV] [VOTE] True Async RFC 1.6 To: Deleu , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: bart+php@croquemonsieur.be (Bart Vanhoutte) > ini settings are very frowned upon, but for the sake of a conversation, w= e can think of it like that. if I do async.enabled =3D 0, then nothing chan= ges for me. Having this opt-in/opt-out control would mean that a broken web= site caused by spawn() only happens if they decide to enable async and they= can start learning and developing their mental habit about how to work wit= h async code. Like I said in my previous email, having a feature flag like this would be a reasonable compromise between adoption and backwards compatibility. Shared state is definitely a problem but there's also less obvious things that can go wrong. For example: database transactions are done on a per connection basis. Sharing a single database connection for purposes other than queries that read things is dangerous. Imagine starting a transaction in one coroutine, doing a couple of inserts and then switching do a different coroutine before committing the transaction. As long as the transaction has not been committed or rolled back, the second coroutine will execute queries on the same connection! As for the feature flag: I would prefer something that can be enabled on a per-project basis. I'm guessing an ini-setting could work? You can enable it in both the configuration and in code (index.php). As an addition, a flag in composer.json that indicates async behavior would be a nice to have. It could warn users when they are requiring a library that does not support async. Best Regards, Bart Vanhoutte Op vr 21 nov 2025 om 15:18 schreef Deleu : > > > > On Fri, Nov 21, 2025 at 10:45=E2=80=AFAM Edmond Dantes wrote: >> >> >> I have a mental habit: when I write asynchronous code, I always assume >> that any object shared between coroutines can change at any moment. >> Similarly, if you hand off memory ownership to another class or share >> memory, you have to keep in mind that there is a chance some developer >> might accidentally do something wrong. >> >> The only difference between synchronous and asynchronous code is that >> you don=E2=80=99t have a precise moment in time when the change happens.= And >> yes, that makes debugging harder. It makes finding bugs harder. But >> it=E2=80=99s not something fundamentally new. > > > I don't know how else to describe it, but I decided to give a last attemp= t here since you mentioned your mental habit: having a mental habit about a= sync code makes perfect sense. What I'm trying to say is that most PHP deve= lopers don't have that mental habit and that's not a problem because Async = code in PHP doesn't come into your project out of nowhere. With `spawn()` b= eing native, anytime you do "composer update" your project may start runnin= g async code without your consent and without warning you that you should g= o through a mental habit that you don't even know exist because you never h= ad to worry about async code before in your life. > > Having spawn() be an extremely easy way to start running async code is a = great feature (not a bug). But the very first thing that seems to be missin= g is: I'm a dumb PHP developer that don't know and don't care about async p= hp and when I upgrade to PHP X.Y, how do I keep my project always-sync with= out risking one of my composer packages suddenly calling spawn() and causin= g bugs I have no idea how to even begin to understand? > > ini settings are very frowned upon, but for the sake of a conversation, w= e can think of it like that. if I do async.enabled =3D 0, then nothing chan= ges for me. Having this opt-in/opt-out control would mean that a broken web= site caused by spawn() only happens if they decide to enable async and they= can start learning and developing their mental habit about how to work wit= h async code. > > -- > Marco Deleu