ForeverLearning has asked for the wisdom of the Perl Monks concerning the following question:
I have an odd thing happening in my script where AnyEvent::HTTP is not releasing variables and just adds data onto the end of a file read.
My main code body calls anyevent
$condvar = AnyEvent->condvar; for (1..$multiLimit) { doProcess(); } $condvar->recv;
doProcess then does:
$condvar->begin; say "Active ${aval}, Offset ${oval}"; ### This was originally another sub, but I brought it inline f +or debug my $content; my $fh = FileHandle->new; if ($debug) { say "Reading ${localfile} offset ${offset} for l +ength ${contentLength}";} $fh->open("< $localfile"); binmode($fh); read($fh,$content,$contentLength,$offset); if ($debug) { say "readData read ".byteSize($content);} $fh->close; ### http_request "PUT" => $url, headers=>$headerVals, body=>$content, sub { my ($body, $hdr) = @_; say "received, Size: ", length $body; say $body; $activeCount--; $condvar->end; doProcess(); }; return 1
And this is the odd behaviour I'm seeing
Active:1, Offset:0 Reading test offset 0 for length 4194303 readData read 4194303 Active:2, Offset:4194304 Reading test offset 4194304 for length 4194303 readData read 8388607 Active:3, Offset:8388608 Reading test offset 8388608 for length 4194303 readData read 12582911
see how readData is being appended and not reset ? Weird huh ! (or, more likely, am I just doing something stoopid ? ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: AnyEvent::HTTP Not releasing variables
by Anonymous Monk on Mar 21, 2016 at 00:30 UTC | |
by ForeverLearning (Novice) on Mar 21, 2016 at 08:44 UTC | |
by Corion (Patriarch) on Mar 21, 2016 at 09:00 UTC | |
by ForeverLearning (Novice) on Mar 21, 2016 at 08:28 UTC |