Closed mkarnicki closed 6 years ago
facepalm
Thank you for the links Dries. I see everyone's complaining and nobody's trying to document it, so I might as well do it myself. Cheers.
For people coming here you can just destruct the object you get.
App\Jobs\SendTasksDigest::dispatch(App\User::find(5))->__destruct();
Please advise if this is a PsyShell bug and not laravel/framework bug, in which case I can file this issue in a more appropriate place.
Description:
Dispatching jobs from artisan tinker session doesn't work correctly with the queue. Any queued job PREV waits for another job NEXT, at which point PREV is handled (but not NEXT, which waits for yet another job). I fully described the issue on SO and got someone to confirm it.
Steps To Reproduce:
Paste the following into the TestQueue class. Nothing fancy, really:
Now, regardless of the QUEUE_CONNECTION env var (
redis
,beanstalkd
, evensync
), I get the following behavior. Please note I havephp artisan queue:work
running in a separate terminal, restarted after any .env changes and config is not cached.$ php artisan tinker
>>> App\Jobs\TestQueue::dispatch(1)
logs:
>>> App\Jobs\TestQueue::dispatch(2)
logs:
>>> App\Jobs\TestQueue::dispatch(3)
logs:
If you're testing with sync queue, ensure that sync driver is set to
sync
and notnull
inconfig/queue.php
EDIT: Note this only happens from artisan tinker session. The jobs are handled correctly via web routes.