Skip Menu |

This queue is for tickets about the AnyEvent-Beanstalk CPAN distribution.

Report information
The Basics
Id: 60118
Status: open
Priority: 0/
Queue: AnyEvent-Beanstalk

People
Owner: Nobody in particular
Requestors: david [...] hisel.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.100790
Fixed in: (no value)



Subject: job->{'client'} does not have proper tube name
I am assuming that the tube name should be passed into the job- Show quoted text
>{'client'} somewhere, further it looks like '__using' attribute should
contain the tube name, but, I've not dug into the code to determine this. Regardless, the tube name does not show up in the $job when the $cb is called. I've attached my test script and the results when run on my machine. I'm running on Ubuntu 9.10, Perl 5.10, and beanstalkd 1.4.6. At the point inside the callback, I need to know the name of the tube. Is there another way to determine tube name? Thanks, .dave.
Subject: blah.txt
JOB1: $VAR1 = bless( { 'buried' => 0, 'client' => bless( { 'priority' => 10000, '_sock' => bless( do{\(my $o = sub { "DUMMY" })}, 'AnyEvent::Util::guard' ), 'delay' => 0, '_condvar' => {}, 'on_error' => undef, 'ttr' => 120, '__watching' => { 'default' => 1 }, 'decoder' => sub { "DUMMY" }, 'encoder' => sub { "DUMMY" }, '_cmd_cb' => sub { "DUMMY" }, 'debug' => 0, '_socket' => \*{'AnyEvent::Socket::'}, 'server' => 'devqueue.local:11300', 'on_connect' => undef, '__using' => 'default' }, 'AnyEvent::Beanstalk' ), 'data' => 'data for one', 'id' => '9' }, 'AnyEvent::Beanstalk::Job' ); JOB2: $VAR1 = bless( { 'buried' => 0, 'client' => bless( { 'priority' => 10000, '_sock' => bless( do{\(my $o = sub { "DUMMY" })}, 'AnyEvent::Util::guard' ), 'delay' => 0, '_condvar' => {}, 'on_error' => undef, 'ttr' => 120, '__watching' => { 'default' => 1 }, 'decoder' => sub { "DUMMY" }, 'encoder' => sub { "DUMMY" }, '_cmd_cb' => sub { "DUMMY" }, 'debug' => 0, '_socket' => \*{'AnyEvent::Socket::'}, 'server' => 'devqueue.local:11300', 'on_connect' => undef, '__using' => 'default' }, 'AnyEvent::Beanstalk' ), 'data' => 'data for two', 'id' => '10' }, 'AnyEvent::Beanstalk::Job' ); INITIAL TUBES WATCHED: $VAR1 = [ 'default' ]; LIST TUBES: $VAR1 = [ 'default', 'one', 'two' ]; NUM WATCHED: $VAR1 = '1'; NUM WATCHED: $VAR1 = '2'; NUM WATCHED: $VAR1 = '3'; LIST TUBES WATCHED: $VAR1 = [ 'default', 'one', 'two' ]; STATS BEFORE: $VAR1 = \bless( { 'total-jobs' => 0, 'current-jobs-delayed' => 0, 'pause-time-left' => 0, 'current-jobs-reserved' => 0, 'name' => 'default', 'current-watching' => 1, 'pause' => 0, 'current-jobs-ready' => 0, 'current-jobs-urgent' => 0, 'current-jobs-buried' => 0, 'cmd-pause-tube' => 0, 'current-waiting' => 0, 'current-using' => 0 }, 'AnyEvent::Beanstalk::Stats' ); Tube, default, jobs ready: 0 $VAR1 = \bless( { 'total-jobs' => 5, 'current-jobs-delayed' => 0, 'pause-time-left' => 0, 'current-jobs-reserved' => 0, 'name' => 'one', 'current-watching' => 1, 'pause' => 0, 'current-jobs-ready' => 5, 'current-jobs-urgent' => 0, 'current-jobs-buried' => 0, 'cmd-pause-tube' => 0, 'current-waiting' => 0, 'current-using' => 0 }, 'AnyEvent::Beanstalk::Stats' ); Tube, one, jobs ready: 5 $VAR1 = \bless( { 'total-jobs' => 5, 'current-jobs-delayed' => 0, 'pause-time-left' => 0, 'current-jobs-reserved' => 0, 'name' => 'two', 'current-watching' => 1, 'pause' => 0, 'current-jobs-ready' => 5, 'current-jobs-urgent' => 0, 'current-jobs-buried' => 0, 'cmd-pause-tube' => 0, 'current-waiting' => 0, 'current-using' => 1 }, 'AnyEvent::Beanstalk::Stats' ); Tube, two, jobs ready: 5 RESERVE A JOB: $VAR1 = \bless( { 'client' => bless( { 'priority' => 10000, '_sock' => bless( do{\(my $o = sub { "DUMMY" })}, 'AnyEvent::Util::guard' ), 'delay' => 0, 'decoder' => sub { "DUMMY" }, 'encoder' => sub { "DUMMY" }, 'debug' => 0, 'server' => 'devqueue.local:11300', '_condvar' => {}, 'ttr' => 120, 'on_error' => undef, '__watching' => { 'default' => 1 }, '_cmd_cb' => sub { "DUMMY" }, '_socket' => \*{'AnyEvent::Socket::'}, 'on_connect' => undef, '_reserve_pending' => 0, '__using' => 'default' }, 'AnyEvent::Beanstalk' ), 'data' => 'date for one', 'id' => '1' }, 'AnyEvent::Beanstalk::Job' ); ID: 1 DATA: date for one STATS AFTER: $VAR1 = \bless( { 'total-jobs' => 0, 'current-jobs-delayed' => 0, 'pause-time-left' => 0, 'current-jobs-reserved' => 0, 'name' => 'default', 'current-watching' => 1, 'pause' => 0, 'current-jobs-ready' => 0, 'current-jobs-urgent' => 0, 'current-jobs-buried' => 0, 'cmd-pause-tube' => 0, 'current-waiting' => 0, 'current-using' => 0 }, 'AnyEvent::Beanstalk::Stats' ); Tube, default, jobs ready: 0 $VAR1 = \bless( { 'total-jobs' => 5, 'current-jobs-delayed' => 0, 'pause-time-left' => 0, 'current-jobs-reserved' => 1, 'name' => 'one', 'current-watching' => 1, 'pause' => 0, 'current-jobs-ready' => 4, 'current-jobs-urgent' => 0, 'current-jobs-buried' => 0, 'cmd-pause-tube' => 0, 'current-waiting' => 0, 'current-using' => 0 }, 'AnyEvent::Beanstalk::Stats' ); Tube, one, jobs ready: 4 $VAR1 = \bless( { 'total-jobs' => 5, 'current-jobs-delayed' => 0, 'pause-time-left' => 0, 'current-jobs-reserved' => 0, 'name' => 'two', 'current-watching' => 1, 'pause' => 0, 'current-jobs-ready' => 5, 'current-jobs-urgent' => 0, 'current-jobs-buried' => 0, 'cmd-pause-tube' => 0, 'current-waiting' => 0, 'current-using' => 1 }, 'AnyEvent::Beanstalk::Stats' ); Tube, two, jobs ready: 5
Subject: blah.pl
#!/usr/bin/perl use strict; use warnings; use Time::HiRes qw( sleep ); use AnyEvent::Beanstalk; use Data::Dumper; # ... config stuff here ... my $server = "devqueue.local"; my $client = AnyEvent::Beanstalk->new( server => $server, ); $client->use('one')->recv; my $job1 = $client->put({ data => "data for one" })->recv; print "JOB1: ", Dumper($job1), "\n"; $client->use('two')->recv; my $job2 = $client->put({ data => "data for two" })->recv; print "JOB2: ", Dumper($job2), "\n"; my $tubes_watched = $client->list_tubes_watched()->recv; print "INITIAL TUBES WATCHED: ", Dumper($tubes_watched); my $tubes = $client->list_tubes()->recv; print "LIST TUBES: ", Dumper($tubes); # Watch all tubes foreach my $t (@$tubes) { my $num_watched = $client->watch($t)->recv; print "NUM WATCHED: ", Dumper($num_watched); } sleep 1; my $tubes_watched2 = $client->list_tubes_watched()->recv; print "LIST TUBES WATCHED: ", Dumper($tubes_watched2); print "STATS BEFORE:\n"; foreach my $tube (@$tubes) { my $stats = $client->stats_tube($tube)->recv; print Dumper(\$stats), "\n"; print "Tube, $tube, jobs ready: ", $stats->{'current-jobs-ready'}, "\n"; } print "RESERVE A JOB:\n"; $client->reserve(1, sub { my $job = shift; process_job($job); })->recv; print "STATS AFTER:\n"; foreach my $tube (@$tubes) { my $stats = $client->stats_tube($tube)->recv; print Dumper(\$stats), "\n"; print "Tube, $tube, jobs ready: ", $stats->{'current-jobs-ready'}, "\n"; } exit 0; sub process_job { my ($job) = @_; print Dumper(\$job); print " ID: ", $job->{'id'}, "\n"; print "DATA: ", $job->{'data'}, "\n"; }
Subject: Re: [rt.cpan.org #60118] job->{'client'} does not have proper tube name
Date: Thu, 5 Aug 2010 15:38:54 -0700
To: bug-AnyEvent-Beanstalk [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
To find the name of the tube that a job came from you have to do a stat on the job $client->stats_job($job->id, sub { my $stats = shift; warn $stats->tube });
On Thu Aug 05 18:39:07 2010, gbarr@pobox.com wrote: Show quoted text
> To find the name of the tube that a job came from you have to do a > stat on the job > > $client->stats_job($job->id, sub { my $stats = shift; warn $stats-
> >tube });
>
How do I do this inside of my process_job() method? $client->reserve(1, sub { my $job = shift; process_job($job); })- Show quoted text
>recv;
sub process_job { my $job = shift; my $tube_name = ???; } Thanks, .dave.
Subject: Re: [rt.cpan.org #60118] job->{'client'} does not have proper tube name
Date: Thu, 5 Aug 2010 22:50:29 -0700
To: bug-AnyEvent-Beanstalk [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Aug 5, 2010, at 4:44 PM, David Hisel via RT wrote: Show quoted text
> How do I do this inside of my process_job() method?
$client->reserve(1, sub { my $job = shift; $client->stats_job($job->id, sub { my $stats = shift; process_job($job, $stats->tube); }) }) Show quoted text
>> recv;
> > sub process_job { > my $job = shift; > my $tube_name = ???; > } > > Thanks, > .dave. >