1nickt has asked for the wisdom of the Perl Monks concerning the following question:

Update: The issue turned out to be a failure in mocking, not a problem per se with Resque. I am mocking Redis (the back end) with Test::Mock::Redis, but somehow Resque is using an unmocked Redis instance for the pop() call (well, the lpop() call on Redis) even though it is using the mocked instance for all the other calls including the peek(). I think the cause is something to do with Moo/Moose inheritance and load order, ie my mocking is happening too late. Odd since I don;t believe I am instantiating the Resque object until after Redis is mocked, but anyhow I am ~ 23.75 hours over the don't-be-stuck-for-more-than-15-minutes rule, so I gave up and now am popping the job off the queue by accessing low-level Redis calls. If I ever figure it out I'll post back here.


Hi all, any Resque users out there? I am using Resque at $work for a job queue and it's mostly working as expected. But I've run into a problem when trying to manually pop a job and process it. The documented way to do that is to use the worker object's reserve() method to get the job, and then process it with work_tick(). But it's not working: no jobs are found. This is really odd since the queue has jobs. I hacked the source for Resque::Worker::reserve() as follows:

sub reserve { my $self = shift; my $count = 0; warn "RESERVING"; for my $queue ( @{$self->queues} ) { warn "QUEUE $queue"; use Data::Dumper; warn "JOBS " . Dumper [ map { $_->{payload} } $self->resque->p +eek($queue) ]; if ( my $job = $self->resque->pop($queue) ) { warn "JOB $job"; return $job; } warn "NO JOBS!!!"; return if ++$count == @{$self->queues}; } }
... and it outputs the jobs from peek() as expected, but does not find any jobs with pop()!
RESERVING at /.../.perlbrew/libs/perl-5.26.1@dev/lib/perl5/Resque/Work +er.pm line 175. QUEUE account_provisioning at /.../.perlbrew/libs/perl-5.26.1@dev/lib/ +perl5/Resque/Worker.pm line 177. JOBS $VAR1 = [ { 'args' => [ ... ], 'start_time' => 1542202068, 'class' => ..., } ]; NO JOBS!!! at /.../.perlbrew/libs/perl-5.26.1@dev/lib/perl5/Resque/Wor +ker.pm line 184.

Any clues will be gratefully received. Thanks!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.