Re: advice needed for spinner



Dear Brian,

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.
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().

I removed email part and added sleep() instead.  It gave me the same result.
This is what I want to do:
1. click "start spin" button
2. spinner become visible and spin
3. child process does a job
4. spinner stops and become invisible automatically.

1. if you see the action of this code, you can tell, that the spinner does not spin until the child process 
finishes its job. the same problem persists if I forked two child processes instead of using run_on_start and 
run_on_finish.  This is where I am puzzled the most.
2. if i remove wait_all_children like you say, spinner does not stop.
3. if i add Gtk3::Spinnder->hide(), the spinner does not show at all.

Since sleep() gives me the same problem, code "spinner_fork_for_question.pl" no longer needed. Inside run_on_start() and run_on_finish(), i added print() to see if they are executed, and they do, but the spinner does not respond right. This is why I am puzzled.

I attached three test cases:
1. spinner_fork_with_wait_all_children_with_hide.pl
Result: Spinner does not show at all!
2. spinner_fork_with_hide_without_wait_all_children.pl
Result: Spinner spin but it does not start til a child process completes, and spinner does not stop.
3. spinner_fork_without_wait_all_children_with_hide.pl
Result: Spinner spin but it does not start til a child process completes, and spinner does not stop.

Thank you.

Tsuyoshi


On 2014年05月30日 02:51, Brian Manning wrote:
Hi,

In the script 'spinner_fork_for_question.pl', you're still calling
Parallel::ForkManager->wait_all_children, which I stated in my
previous e-mail is a blocking call.  Are you going to remove that
method call at some point?

Also, can you simplify 'spinner_fork_for_question.pl'?  You could
remove the e-mail sending bits, and replace it instead with a call to
qx(sleep), or some other external process that will block for a few
seconds, and most likely get the same result.

The script "gtk3_spinner_fork2.pl" worked for me.

Thanks,

Brian

On Wed, May 28, 2014 at 10:00 PM, tsuyoshi okita <825864 gmail com> wrote:
Dear Brian and others,

Thank you for your quick reply, Brian-san.
Instead of forking two process, I've decided to fork only one process for
sending an email,and using run_on_start and run_on_finish for the spinner.
And the same problem still persists. Strange thing is that I added print
"run_on_start" and print "run_on_finish" to each callback subroutines to
make sure they are processed.  They do, but spinners do not respond right.

In other code using Parallel::ForkManager, Spinner worked fine, it spin and
stopped when I expected. but when forked to send an email, spinner gets
grumpy all the sudden.
I attached two test cases, one is a revised but problem still persists code,
and other works sort of fine.

There is other problem I need your guide for.  when I add hide() for spinner
after stop(), spinner does not show at all.  Have you had this problem??

Thank you again.

Tsuyoshi


On 2014年05月29日 12:04, Brian Manning wrote:
Your sample code uses Parallel::ForkManager, and uses the
wait_all_children method to wait for the children to end processing.
  From the Parallel::ForkManager docs:

-begin quote-

wait_all_children

You can call this method to wait for all the processes which have been
forked. This is a blocking wait.

-end quote-

So you are calling a method that says it will block, hence your demo
script is blocking.

Instead of using "wait_all_children" (which blocks), I would look at
using the "run_on_finish" callback method instead, and make the call
to stop the spinner from that callback method.

Thanks,

Brian

On Wed, May 28, 2014 at 7:27 PM, tsuyoshi okita <825864 gmail com> wrote:
Dear gurus,

I've been trying let a spinner spins at the same time sending an email by
forking and failing.  Although a program forks, and one child process
suppose to spin the spinner while other sends email, the spinner does not
spin until the email is completely sent.  How does you all usually handle
this spinner thingy???  Am i on a right path??

I attached my test case.  You need to add SMTP host name, your email
address, and password.

Thank you.

Tsuyoshi

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Attachment: spinner_fork_with_hide_without_wait_all_children.pl
Description: Perl program

Attachment: spinner_fork_with_wait_all_children_with_hide.pl
Description: Perl program

Attachment: spinner_fork_without_wait_all_children_with_hide.pl
Description: Perl program



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