in reply to MozRepl cleanup problem

These messages come from when the global destruction of objects happens. The global destruction does not respect the usual order of object destruction anymore, and in your case, this means that sometimes there are Javascript proxy objects still alive while the bridge to Firefox has gone down already.

I told you on StackOverflow to undef $mech. If that doesn't solve your problems, maybe you keep other references into Firefox. You need to break these references before starting global destruction as well.

Update: It seems that you're creating a WWW::Mechanize::Firefox object over and over again in a loop. Most likely, you'll be better off by creating your object outside of your loop - at least that should be faster as the initialization within Firefox then only needs to happen once.

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

    First of all, thanks for the fast reply.

    I tried moving the creation of $firemech outside the loop, but this resulted in making the script hang after changing to the second page. To explain further, it connected to the first page, got everything I asked for, then it connected to the second one (could see it in Firefox), but nothing happened. I waited something like 5 minutes, it didn't even timeout.

    Could you explain again what you mean by "maybe you keep other references into Firefox"? I didn't understand what should I break of all the stuff I use for those cycles.

      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.

        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.