Replies: 2 comments
-
Both coroutine and async/await have the goal of making using promises a lot easier to read. They differ in how they work behind the scenes but you should see the same result. Given you seen to be dealing with a database and the Discord API that 0.1 second could trigger both earlier or later then it completes your coroutine. |
Beta Was this translation helpful? Give feedback.
-
Hi @sherwomeister, thank you for bringing this up. Could you please confirm if you are using PHP 8.1+? If you are, I would recommend using async v4 and await with fibers for better performance. It seems like you are attempting to execute commands in a specific order, but encountering timing issues. Depending only on timers can be unpredictable, unless it is for demonstration purposes in your example. I suggest considering the use of await for each individual time step instead. |
Beta Was this translation helpful? Give feedback.
-
I have this code for my discord bot. I am using DiscordPHP library that is built on ReactPHP.
This outputs:
acb
If I change code and use async()/await(), everything works just fine:
abc
Maybe I misunderstood coroutine's purpose?
Beta Was this translation helpful? Give feedback.
All reactions