Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Thread::Queue and WWW::Curl
by Corion (Patriarch) on Sep 24, 2012 at 14:33 UTC | |
|
Re: Thread::Queue and WWW::Curl
by BrowserUk (Patriarch) on Sep 24, 2012 at 14:42 UTC | |
by Anonymous Monk on Sep 24, 2012 at 14:53 UTC | |
by BrowserUk (Patriarch) on Sep 24, 2012 at 15:04 UTC | |
by Anonymous Monk on Sep 24, 2012 at 15:12 UTC | |
by BrowserUk (Patriarch) on Sep 24, 2012 at 15:48 UTC | |
by Anonymous Monk on Sep 24, 2012 at 15:45 UTC | |
|
Re: Thread::Queue and WWW::Curl
by Anonymous Monk on Sep 24, 2012 at 14:25 UTC |