Hi Mario,

Yes, this code with the two changes to MCE::Shared::Server is working exactly as expected when run to completion, and when interrupted with CTL-C. Nice!

For completion I wanted to test what would happen with an uncaught exception, so I added a fatal operation to the loop:

for ( @{ $chunk_ref } ) { say $_ / 0 if $_ == 4;
... which resulted in the worker dying with the expected exception and message from Perl, while the manager and the other workers continued to completion, including updating the shared hash:
perl mce10.pl Parent PID 29953 worker 2 (29957) processing chunk 1 worker 1 (29956) processing chunk 2 worker 2 (29957) processing chunk 3 worker 1 (29956) processing chunk 4 worker 1 (29956) processing chunk 6 worker 2 (29957) processing chunk 5 Illegal division by zero at mce10.pl line 27, <__ANONIO__> line 6. Hello from END block: 29957 worker 1 (29956) processing chunk 7 Hello from END block: 29956 Hello from END block: 29953 Parent in END: $VAR1 = bless( { '00 29957' => '1491661589', '01 29956' => '1491661589', '02 29957' => '1491661591', '03 29956' => '1491661591', '05 29956' => '1491661593', '06 29956' => '1491661595' }, 'MCE::Shared::Hash' );
... note the missing key for #4.

I think that this is a good optional behaviour. But I think it would be nice to have the default case be: that an uncaught exception kills the whole program. One could choose to have the manager ignore an exception in a worker process, via a switch of some kind (maybe an option to MCE::Signal ?). But in that case I think it would be important to document the behaviour as demonstrated above, so users can know that the shared data cache will not necessarily contain all the expected data.

So that by default one can count on: either the shared data structure being populated as expected, or an exception ... a partially-populated data structure should only be provided on demand and with a warning.

Thank you again.


The way forward always starts with a minimal test.

In reply to Re^6: Interrupt multi-process program while using MCE::Shared hash: END block code does not (all) run by 1nickt
in thread Interrupt multi-process program while using MCE::Shared hash: END block code does not (all) run by 1nickt

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.