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 ? ;-)


In reply to AnyEvent::HTTP Not releasing variables by ForeverLearning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.