Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: fork() on win10 - MCE (released 1.883 update)

by marioroy (Prior)
on Jan 04, 2023 at 00:02 UTC ( [id://11149352]=note: print w/replies, xml ) Need Help??


in reply to Re^2: fork() on win10 - MCE
in thread fork() on win10

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

Replies are listed 'Best First'.
Re^4: fork() on win10 - MCE (released 1.883 update)
by kcott (Archbishop) on Jan 04, 2023 at 10:45 UTC

    G'day Mario,

    I saw this being discussed in the CB, but the data is a bit too big for there. I attempted installation of MCE and MCE::Shared on Cygwin and MSWin. Cygwin was completely successful. MSWin didn't pick up the latest (1.883) version of MCE, nor the latest (1.880) version of MCE::Shared. Details follow.

    Cygwin

    Cygwin (on Win10) with Perl v5.36.0 (Perlbrew):

    cpan[1]> install MCE ... MARIOROY/MCE-1.883.tar.gz /usr/bin/make -- OK ... MARIOROY/MCE-1.883.tar.gz /usr/bin/make test -- OK ... MARIOROY/MCE-1.883.tar.gz /usr/bin/make install -- OK cpan[2]> install MCE::Shared ... MARIOROY/MCE-Shared-1.880.tar.gz /usr/bin/make -- OK ... MARIOROY/MCE-Shared-1.880.tar.gz /usr/bin/make test -- OK ... MARIOROY/MCE-Shared-1.880.tar.gz /usr/bin/make install -- OK

    I'm set up as a CPAN Tester on this platform; green swatches in the post, i.e. awaiting matrix update. :-)

    MSWin

    Windows 10 with Strawberry Perl v5.26.3:

    Microsoft Windows [Version 10.0.19045.2364] (c) Microsoft Corporation. All rights reserved. ... cpan> install MCE Database was generated on Tue, 03 Jan 2023 22:15:36 GMT MCE is up to date (1.882). cpan> install MCE::Shared ... MARIOROY/MCE-Shared-1.879.tar.gz C:\Users\ken\local\opt\strawberry_perl\5_026_003\install\c\bin\gmake +.exe -- OK ... MARIOROY/MCE-Shared-1.879.tar.gz C:\Users\ken\local\opt\strawberry_perl\5_026_003\install\c\bin\gmake +.exe test -- OK ... MARIOROY/MCE-Shared-1.879.tar.gz C:\Users\ken\local\opt\strawberry_perl\5_026_003\install\c\bin\gmake +.exe install UNINST=1 -- OK

    So, MCE v1.883 wasn't found/identified/whatever and v1.882 was up to date; and, MCE::Shared v1.880 wasn't found/identified/whatever and v1.879 was installed successfully.

    I'll be happy to test further; let me know.

    — Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-24 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found