in reply to Re^2: MozRepl cleanup problem
in thread MozRepl cleanup problem

All the data you pull out of Firefox as HTML elements (through the ->xpath method or the ->selector method, for example), keeps the bridge into Firefox alive. So you need to make sure you don't have any more such objects lying around when you want a clean exit (or you just ignore the warning messages).

I'm not sure why the script would hang at the second round. Maybe the site does not load some data it loads on the first round. You'll have to debug the behaviour of the site when automating it.

Replies are listed 'Best First'.
Re^4: MozRepl cleanup problem
by giantpanda (Initiate) on Oct 30, 2010 at 17:41 UTC

    Sadly, I can't ignore the warnings as when they appear it means the script has abruptly ended itself (before the real end of the cycle).

    As a note, I'm 100% sure that the data I'm looking for is in the page and gets loaded properly since I checked again and since it's one of the pages I usually use to test the script.

    Anyway, I tried cleaning everything I could from the cycle and nothing changed. Still same errors, plus this one occasionally:

    Failed to connect to , command timed-out at /Library/Perl/5.10.0/MozRepl/Client.pm line 186

    I undefined: firemech, content, date, retries, game, longid, shortid, matchid, flag. I know some of these are probably not the cause of my issues, but it was worth a try. I have no idea how to undefine anything about xpath since I didn't copy it anywhere (just checked it was in the page).

    Anything else I have missed or that I might try? Again, thanks for your patience.

      Sadly, I can't ignore the warnings as when they appear it means the script has abruptly ended itself (before the real end of the cycle).

      No. Global destruction happens at the end of your program, not somewhere in the middle. If you fork(), you maybe get that, so don't do that then.

      If you post a complete, self-contained example that reproduces the problem but is not longer than 20 lines, that would help me to help you better. I could then try to reproduce what you're seeing and maybe find what causes it easier.

        I managed to make a reduced version of that part of my script, sadly I couldn't manage to reduce it under 50 lines.
        Would that be fine for you?

        UPDATE: Here is the code and some nicknames to test it:

        #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; use WWW::Mechanize; use Date::Manip; use DateTime; open TXT, "<", "nickname.log"; while(! eof (TXT)){ my $nick = <TXT>; chomp $nick; open MATCH, "+<", "match.log"; my $j = 0; for $j(0..3){ my ($date) = DateTime->now; my ($k) = 0; while($k < $j){ $date = $date->subtract( days => 7); $k++; } $date = $date->ymd; my $url = "http://www.quakelive.com/#profile/matches/$nick/$da +te"; my ($firemech) = WWW::Mechanize::Firefox->new(); $firemech->get($url); die "Cannot connect to $url\n" if !$firemech->success(); my ($retries) = 10; while ($retries-- and ! $firemech->is_visible( xpath => '/ +/*[@class="areaMapC"]' )) { sleep 1; } die "Timeout" unless $retries; my ($content) = $firemech->content(); while(($content =~ /class="areaMapC" id="([^<]+)_([^<]+)_([^<] ++)">/gsi)){ my ($game) = $1; my ($longid) = $2; my ($shortid) = $3; my ($matchid) = "$longid/$game/$shortid\n"; print MATCH $matchid; } undef $firemech; undef $content; $j++; } close MATCH; } close TXT;

        Nicknames:

        peavey trajan komap bluedawg donpidon x9rcist dom_prova_____ newton burn tyryl st1mz tomo32 zky hisarrzulu _luk__47_ sendhu joopsta sand5pid3r trickle mikenoid beg1nner fladder72 4bsan1ty daitarn z0id0uf amoreno stuntt askkk flyttadig arcsign glavic acid_predator new_0 jala1 crucci niko95 deputydawg optixx ennesit martianbuddy b4r r1dah gathion function9 chup4 poocamshot shnipzr heppo b4byb34r the_hulk