Re: advice needed for spinner



Hi Tsuyoshi,

On Fri, May 30, 2014 at 2:28 AM, tsuyoshi okita <825864 gmail com> wrote:
I commented wait_all_children like you said and tried, and the spinner does not stop.
The script "gtk3_spinner_fork2.pl" has wait_all_children as well.  I just commented and tested, and the spinner does not stop. it just keeps spinning.

You're stopping the spinner in the on_finish hook, which is NOT executed anymore, now that you don't wait for your children to finish.

I followed a sample code from Parallel::ForkManager CPAN site, and in it it has wait_all_children() stated even though it has run_on_finish() and run_on_start().  This is the reason why I left wait_all_children().

Tough luck, that's the way Parallel::ForkManager seems to work, you really have to wait on your children in order to get some control "on finish".
 
I removed email part and added sleep() instead.  It gave me the same result.
    # print statements
    $pid[0] = $pm->start;
        sleep 2;
    $pm->finish(1);

Where does that "sleep" line gets executed? In BOTH parent process and child/process!
You'll be able to fix this quickly, of course.

That "wait_all_children" bit will hinder getting you anywhere though, as you'll still block the GUI process waiting for children to finish. Get in touch with some Parallel::ForkManager pundit, and if they offer you a straight-through solution, please come back with a reply on this thread. Thanks! :)

Given that your command of Parallel::ForkManager looks quite shallow, I'd recommend taking some time to understanding the way that module works… and realizing that you might on the wrong path, oops :(

Until then, here's a Sunday hack on your code that drops Parallel::ForkManager dependency altogether, and even tries to make it work in "frenzy" mode (i.e. activating "start" and "stop" like crazy): it fails (on my desktop at least), as it randomly segfaults at some "stop". This would be the "gtk3-spinner.pl" attachment.

Ok, I went overboard and baked a version – gtk3-spinners.pl – that shows a spinner for each worker. It's terribly pointless, agreed, but still fun… at least until getting hit with the same segfaults storm as the previous toy. ;-)

Hoping these bits helped your endeavor, have a nice Sunday! :)

~ab

Attachment: gtk3-spinner.pl
Description: Binary data

Attachment: gtk3-spinners.pl
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]