Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Here I have nested forks with objects created prior to for loops. When $html = $mech->content; and $html .= $mech->content; happens it seem to mix up concurrent $mech object. My result is wrong document elements in my temporary files.

This is an upgrade to my existing production code which only runs one FireFox and does not use multiple FireFox profiles and Mozrepl tcp/ip ports.

for each $country_key (keys %$countries) { $fork_countries->start and next; ... foreach $case_no (keys %$case) { $fork_cases->start and next; #do DBIx stuff to get random $ff_profile / avoid race condition $ff_port = 42420 + $ff_profile; &myMain($ff_profile, $ff_port); $fork_cases->finish; } $fork_cases->wait_all_children; $fork_countries->finish; } $fork_countries->wait_all_children; sub myMain { $mech = WWW::Mechanize::Firefox->new( launch => ['firefox','-P',$ff_profile,-no-remote'], repl => "localhost:$ff_port", bufsize => 10_000_000, tab => 'current', autoclose => 1 ); $mech->get($url); $url = $new_url; ### KLUDGED HERE ### # # $temp = $mech->uri; # (undef, $uri) = split(/(\?.*)/, $temp); # $url .= $uri; # ### $html = $mech->content; $mech->get($url); #or eval, click(), etc. $html .= $mech->content; #open temp filehandle and print $html #(temp filenames padded with String::Random) $mech->get(temp_filename); $png = $mech->content_as_png; #add png to PDF with PDF::API2 #write PDF file }

According to what I can find on Parallel::ForkManager each forked $mech and $html should be separate. However, when the $url is the same in each fork either the $mech object, or the $html scalar get mix up.

Then what happens when I do some other method, say $mech->eval() then $html .= $mech->content; the $html I want to print to temp file is mixed with what I thought should be totally separate FireFox profiles and HTTP sessions.

In reply to [solved] Parallel::ForkManager memory mixup? by ground0

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (10)
    As of 2014-07-29 21:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (229 votes), past polls