add tasks does not seem to copy workload correctly

Bug #379586 reported by James M. Luedke
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman::XS
Fix Released
High
Dennis Schön

Bug Description

#!/usr/bin/perl -w

$|++;

use strict;
use warnings;
use Gearman::XS::Client;
use Gearman::XS qw(:constants);

my $client = new Gearman::XS::Client;
my $ret = $client->add_server("127.0.0.1", 0);
$client->set_complete_fn(\&complete);
$client->set_created_fn(\&created);

for my $n (1..5) {
    my ($rv, $task) = $client->add_task('reverse', "$n ha");
 if ($rv != GEARMAN_SUCCESS) {
  die $client->error(),"\n";
 }
 print "server: task added with data: $n ha\n";
}

$client->run_tasks();

sub complete {
 my ($task) = @_;
 my $data = $task->data();
 print "server: complete called with data: $data\n";
    return GEARMAN_SUCCESS;
}

sub created {
 my ($task) = @_;
 print "server: created called with job: " . $task->job_handle() . "\n";
    return GEARMAN_SUCCESS;
}

exit;

---
result
---

server: task added with data: 1 ha
server: task added with data: 2 ha
server: task added with data: 3 ha
server: task added with data: 4 ha
server: task added with data: 5 ha
server: created called with job: H:degobah:135
server: created called with job: H:degobah:136
server: created called with job: H:degobah:137
server: created called with job: H:degobah:138
server: created called with job: H:degobah:139
server: complete called with data: ah 5
server: complete called with data: ah 5
server: complete called with data: ah 5
server: complete called with data: ah 5
server: complete called with data: ah 5

---
worker result
---

Job=H:degobah:135 Workload=5 ha Result=ah 5
Job=H:degobah:136 Workload=5 ha Result=ah 5
Job=H:degobah:137 Workload=5 ha Result=ah 5
Job=H:degobah:138 Workload=5 ha Result=ah 5
Job=H:degobah:139 Workload=5 ha Result=ah 5

Related branches

Changed in gearmanxs:
assignee: nobody → Dennis Schön (roccoblues)
importance: Undecided → High
milestone: none → 0.2
status: New → Confirmed
Changed in gearmanxs:
status: Confirmed → Fix Committed
Revision history for this message
James M. Luedke (jluedke) wrote :

Works like a charm, good work.

Revision history for this message
Dennis Schön (roccoblues) wrote : Re: [Bug 379586] Re: add tasks does not seem to copy workload correctly

Hi,

On 23.05.2009, at 18:44, "James M. Luedke" <email address hidden>
wrote:

> Works like a charm, good work.

Well thanks for finding and reporting that one.

cheers,
Dennis

> --
> add tasks does not seem to copy workload correctly
> https://bugs.launchpad.net/bugs/379586
> You received this bug notification because you are a member of
> Gearman-
> developers, which is the registrant for GearmanXS.
>
> Status in Gearman Perl Frontend: Fix Committed
>
> Bug description:
> #!/usr/bin/perl -w
>
> $|++;
>
> use strict;
> use warnings;
> use Gearman::XS::Client;
> use Gearman::XS qw(:constants);
>
> my $client = new Gearman::XS::Client;
> my $ret = $client->add_server("127.0.0.1", 0);
> $client->set_complete_fn(\&complete);
> $client->set_created_fn(\&created);
>
> for my $n (1..5) {
> my ($rv, $task) = $client->add_task('reverse', "$n ha");
> if ($rv != GEARMAN_SUCCESS) {
> die $client->error(),"\n";
> }
> print "server: task added with data: $n ha\n";
> }
>
> $client->run_tasks();
>
> sub complete {
> my ($task) = @_;
> my $data = $task->data();
> print "server: complete called with data: $data\n";
> return GEARMAN_SUCCESS;
> }
>
> sub created {
> my ($task) = @_;
> print "server: created called with job: " . $task->job_handle() .
> "\n";
> return GEARMAN_SUCCESS;
> }
>
> exit;
>
>
>
> ---
> result
> ---
>
> server: task added with data: 1 ha
> server: task added with data: 2 ha
> server: task added with data: 3 ha
> server: task added with data: 4 ha
> server: task added with data: 5 ha
> server: created called with job: H:degobah:135
> server: created called with job: H:degobah:136
> server: created called with job: H:degobah:137
> server: created called with job: H:degobah:138
> server: created called with job: H:degobah:139
> server: complete called with data: ah 5
> server: complete called with data: ah 5
> server: complete called with data: ah 5
> server: complete called with data: ah 5
> server: complete called with data: ah 5
>
> ---
> worker result
> ---
>
> Job=H:degobah:135 Workload=5 ha Result=ah 5
> Job=H:degobah:136 Workload=5 ha Result=ah 5
> Job=H:degobah:137 Workload=5 ha Result=ah 5
> Job=H:degobah:138 Workload=5 ha Result=ah 5
> Job=H:degobah:139 Workload=5 ha Result=ah 5
>

Revision history for this message
Jeremy Zawodny (jeremy-zawodny) wrote :

Thanks for the fix, guys.

I had started working with Gearman::XS and found the bug. James was helpful enough to sanity check what I was doing and dig deeper into the problem.

Jeremy

Changed in gearmanxs:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.