Hello Monks I am taking baby steps in creating a Boss/Worker threading I have liberally used the example at Re: Perl Threads Boss/Worker Example to create the following:
my ($accessToken, $appId, $userId) = (shift, shift, shift); use threads; use Thread::Queue; use WWW::Curl::Easy; use WWW::Curl::Form; my $threadLimit = 1; my $testUsers=listTestUsersFull($accessToken, $appId); my $q = Thread::Queue->new(); # A new empty queue # Worker threads my @thr = map { threads->create(sub { while (my @item = $q->dequeue(2)) { # assuming undef isn't a valid value and so can be a marker. last unless defined $item[0]; last unless defined $item[1]; deleteUser($item[1], $appId, $item[0]); } } , $appId )->detach(); } 1..$threadLimit; # Send work to the threads @testUsers = @testUsers[1..5]; foreach (keys %{$testUsers}){ $q->enqueue($userId, $$testUsers{$userId}->{access_token}); } # send markers. $q->enqueue(undef) for (1..$threadLimit); # terminate. $_->join() for @thr;
the deleteUser subroutine calls another which contains
, thus sending a simple form. My problem is the subroutine with those WWW::Curl:: calls returns at the line that posts the form: my $response = $curl->perform; however when called via a non-threaded subroutine, everything just works. The documentation for WWW::Curl states threading is hopefully possible.use WWW::Curl::Easy; use WWW::Curl::Form;
I am hoping to gain some wisdom on my problem, I thank you!
In reply to Thread::Queue and WWW::Curl by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |