in reply to Re^5: Interrupt multi-process program while using MCE::Shared hash: END block code does not (all) run
in thread Interrupt multi-process program while using MCE::Shared hash: END block code does not (all) run
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:
... 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:for ( @{ $chunk_ref } ) { say $_ / 0 if $_ == 4;
... note the missing key for #4.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' );
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Interrupt multi-process program while using MCE::Shared hash: END block code does not (all) run
by marioroy (Prior) on Apr 09, 2017 at 06:45 UTC | |
by 1nickt (Canon) on Apr 09, 2017 at 19:56 UTC |