deliciousbrains / wp-queue

Job queues for WordPress
MIT License
164 stars 38 forks source link

Queue processing issue #3

Open code2prog opened 6 years ago

code2prog commented 6 years ago

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 commented 6 years ago

Ping :)

martijn94 commented 6 years ago

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()

rorymcdaniel commented 6 years ago

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

rorymcdaniel commented 6 years ago

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.