-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: event_base_loop reentrant invocation #24
Comments
Which version of this package are you using? |
@WyriHaximus, Tested on PHP 8.1.0 and PHP 8.1.1 |
Here you tried: <?php
use React\EventLoop\Loop;
use React\Promise\Deferred;
use function React\Async\async;
use function React\Async\await;
require __DIR__ . '/vendor/autoload.php';
Loop::addTimer(0, async(function () {
$deferred = new Deferred();
Loop::addTimer(0, static fn() => $deferred->resolve());
await($deferred->promise());
})); Or using https://github.com/reactphp/promise-timer#sleep <?php
use React\EventLoop\Loop;
use React\Promise\Deferred;
use function React\Async\async;
use function React\Async\await;
use React\Promise\Timer\sleep;
require __DIR__ . '/vendor/autoload.php';
Loop::addTimer(0, async(function () {
await(sleep(0));
})); |
Thanks, there is no problem with |
Forgotten Line 44 in ff11a7a
But if Loop::run() is already called before await() is called, then this causes various problems.
Another example <?php
use React\EventLoop\Loop;
use React\Promise\Deferred;
use function React\Async\await;
require __DIR__ . '/vendor/autoload.php';
Loop::futureTick(/* missed await */ function () {
$deferred = new Deferred();
Loop::addTimer(0, static fn() => $deferred->resolve());
await($deferred->promise());
});
Loop::futureTick((static fn() => 0));
As a result, we do not know the problem file and line. It's very easy to miss Maybe just throw an exception instead of calling |
We MIGHT always wrap loop handers in an But I'll also open a PR to test this package against all event loops we support because honestly I only develop and tested it against
Because that |
Excellent input! The Technically, we could also wrap this automatically for each callback, but this incurs a significant overhead. This is especially true as we would have to do this for each callback even if it does not use At the moment, explicitly using |
@Provoker Which version of |
@WyriHaximus, Latest stable from pecl
|
Hello.
The following code is causing an error:
EventBase::loop(): event_base_loop: reentrant invocation. Only one event_base_loop can run on each event_base at once.
Tested on ExtEventLoop.
The text was updated successfully, but these errors were encountered: