Hi ++marioroy,

That's very cool. Now when one of the workers encounters a fatal exception the whole program ends.

But, of course, one has no guarantee of which tasks might have been completed (especially in a real-world scenario where task execution time varies and there are more than just two workers). So even with the program exiting via __DIE__, one can easily wind up with not only a partially populated hash/cache (as expected on early exit), but a hash partially populated *out of sequence* compared to the array being processed by mce_loop. E.g.:

Parent PID 21987 worker 2 (21990) processing chunk 1 worker 1 (21989) processing chunk 2 worker 1 (21989) processing chunk 4 worker 2 (21990) processing chunk 3 worker 1 (21989) processing chunk 6 worker 2 (21990) processing chunk 5 Illegal division by zero at mce12.pl line 35, <__ANONIO__> line 6. Hello from END block: 21990 ## mce12.pl: caught signal (__DIE__), exiting Hello from INT: 21989 Hello from END block: 21989 Hello from END block: 21987 Parent in END: $VAR1 = { '00 21990' => '1491767068', '01 21989' => '1491767068', '02 21990' => '1491767070', '03 21989' => '1491767070', '05 21989' => '1491767072' };
That was of course completely foreseeable, but I hadn't thought about it when asking for default DIE behaviour. Now, since it makes no difference in terms of the issue I first thought of (patchy-incomplete results), I think I may be more likely to favour the previous behaviour; in other words, continue processing even when one worker dies unexpectedly. Haha, sorry! Well, I think both choices are valuable and most needed, actually.

Thanks again.


The way forward always starts with a minimal test.

In reply to Re^8: 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.