To reproduce this, use examples/pubsub.php, and add the following line before foreach ($subscription ...):
EventLoop::delay(2, $subscription->unsubscribe(...));
You'll face an exception as follows:
PHP Fatal error: Uncaught Amp\Pipeline\DisposedException: The iterator has been disposed in vendor/amphp/pipeline/src/Internal/QueueState.php:191
Stack trace:
#0 vendor/amphp/pipeline/src/Internal/ConcurrentQueueIterator.php(45): Amp\Pipeline\Internal\QueueState->dispose()
#1 vendor/amphp/redis/src/RedisSubscription.php(51): Amp\Pipeline\Internal\ConcurrentQueueIterator->dispose()
#2 example.php(24): Amp\Redis\RedisSubscription->unsubscribe()
#3 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(602): {closure:examples/pubsub.php:23}()
#4 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->{closure:Revolt\EventLoop\Internal\AbstractDriver::createCallbackFiber():565}()
#5 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(502): Fiber->resume()
#6 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(558): Revolt\EventLoop\Internal\AbstractDriver->invokeCallbacks()
#7 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->{closure:Revolt\EventLoop\Internal\AbstractDriver::createLoopFiber():538}()
#8 vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(96): Fiber->start()
#9 vendor/revolt/event-loop/src/EventLoop/Internal/DriverSuspension.php(117): Revolt\EventLoop\Internal\AbstractDriver->{closure:Revolt\EventLoop\Internal\AbstractDriver::__construct():90}()
#10 vendor/amphp/pipeline/src/Internal/QueueState.php(128): Revolt\EventLoop\Internal\DriverSuspension->suspend()
#11 vendor/amphp/pipeline/src/Internal/ConcurrentQueueIterator.php(55): Amp\Pipeline\Internal\QueueState->continue()
#12 vendor/amphp/redis/src/RedisSubscription.php(41): Amp\Pipeline\Internal\ConcurrentQueueIterator->getIterator()
#13 example.php(27): Amp\Redis\RedisSubscription->getIterator()
#14 {main}
thrown in vendor/amphp/pipeline/src/Internal/QueueState.php on line 191
Is this a bug, or did I overlook a method allowing me to safely unsubscribe?
Thanks,
Thomas
To reproduce this, use
examples/pubsub.php, and add the following line beforeforeach ($subscription ...):You'll face an exception as follows:
Is this a bug, or did I overlook a method allowing me to safely unsubscribe?
Thanks,
Thomas