wp-queue icon indicating copy to clipboard operation
wp-queue copied to clipboard

Queue processing issue

Open code2prog opened this issue 7 years ago • 4 comments

I have a problem with this library. Jobs are added to the database but are not performed. Single event is created with name wp_queue_connections_databaseconnection and after few moments it disappears from Event list. My code:

$items = [
        'test 1',
        'test 2',
        'test 3',
        'test 4',
    ];

    foreach ($items as $item) {
        wp_queue()->push(new \Some_Class\Backup_Job($item));
    }

    wp_queue()->cron();

Job class:

namespace Some_Class;


use WP_Queue\Job;

class Backup_Job extends Job
{
    public $name;

    /**
     * Backup_Job constructor.
     * @param $name
     */
    public function __construct($name)
    {
        $this->name = $name;
    }

    public function handle()
    {
        sleep(1);
    }

}

Jobs in DB: 2018-02-12_21-07-53

Jobs are not fail. Just stuck in wp_queue_jobs

code2prog avatar Feb 12 '18 21:02 code2prog

Ping :)

code2prog avatar Feb 21 '18 22:02 code2prog

Do your jobs get processed when u manually call the worker?

This way you know if it's a problem with WP_Cron or the actual queue.

wp_queue()->worker()->process()

martijn94 avatar Mar 05 '18 10:03 martijn94

I'm having the exact same issue, even when I manually call wp_queue()->worker()->process()

rorymcdaniel avatar Mar 27 '18 15:03 rorymcdaniel

I should add that it appears my issue was caused by problems in a script called by my Job class. Once I resolved this issue, manually calling the worker appears to have worked. That being said, I feel like this is when it should have been marked as a failed job.

rorymcdaniel avatar Mar 27 '18 18:03 rorymcdaniel