Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I wonder if sleep is broken or if the box is busy or delays coming from Windows anti-malware? Looking at tests 4, 5, and 8.

perl -Ilib t/05_mce_child.t ... ok 2 - spawning asynchronously ok 3 - check for unique pids ok 4 - check list_running ok 5 - check list_joinable ok 6 - check list ok 7 - check pending ok 8 - check is_running child1 ok 9 - check is_joinable child1 ok 10 - check is_running child2 ok 11 - check is_joinable child2 ok 12 - check is_running child3 ok 13 - check is_joinable child3 ...

Is there an alternative to sleep on the Windows platform, ensuring delay before the workers exit?

{ my ( $cnt, @list, %pids, %ret ); local $_; my ( $come_then_i_pray ) = ( "さあ、私&#123 +99;祈る" . "Ǣ" ); ok( 1, "spawning asynchronously" ); # test 2 MCE::Child->create( sub { sleep 1; sleep 1; "$come_then_i_pray $_" +} ) for ( 1..3 ); %pids = map { $_ => undef } MCE::Child->list_pids; is ( scalar( keys %pids ), 3, 'check for unique pids' ); # test 3 @list = MCE::Child->list_running; is ( scalar @list, 3, 'check list_running' ); # test 4 @list = MCE::Child->list_joinable; is ( scalar @list, 0, 'check list_joinable' ); # test 5 @list = MCE::Child->list; is ( scalar @list, 3, 'check list' ); # test 6 is ( MCE::Child->pending, 3, 'check pending' ); # test 7 $cnt = 0; for ( @list ) { ++$cnt; is ( $_->is_running, 1, 'check is_running child'.$cnt ); # te +sts 8, 10, 12 is ( $_->is_joinable, '', 'check is_joinable child'.$cnt ); # te +sts 9, 11, 13 } $cnt = 0; for ( @list ) { ++$cnt; $ret{ $_->join } = 1; is ( $_->error, undef, 'check error child'.$cnt ); } is ( scalar keys %ret, 3, 'check for unique values' ); for ( sort keys %ret ) { my $id = chop; s/ $//; is ( $_, $come_then_i_pray, "check for utf8 string $id" ); }; }

Update 1: I have an idea to not use sleep. Instead, I will have workers read a channel. The manager process will notify workers to exit after completing tests list_running, list_joinable, list, pending, is_running, and is_joinable.

Update 2: Released MCE 1.883 on meta::cpan


In reply to Re^3: fork() on win10 - MCE (released 1.883 update) by marioroy
in thread fork() on win10 by BernieC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found