Subject: | Better handling of Storable errors |
If the returned data contains something Storable cannot handle, then the error handling is not so good:
$ perl5.22.0 -MParallel::WorkUnit -e '$pwu = Parallel::WorkUnit->new; $pwu->async(sub { qr{xxx} }, sub { $res = $_[0] }); $pwu->waitall'
Argument "ERROR" isn't numeric in numeric lt (<) at /opt/perl-5.22.0/lib/site_perl/5.22.0/Parallel/WorkUnit.pm line 187, <GEN0> line 2.
Magic number checking on storable string failed at /opt/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Storable.pm line 420, <GEN0> line 2, at /opt/perl-5.22.0/lib/site_perl/5.22.0/Parallel/WorkUnit.pm line 195.
Problem is that $type is already sent to the pipe, and after that the Storable::freeze error happens. It would be better to call Storable::freeze before anything was sent to the pipe, so the error message is much better:
Child died with error: Can't store REGEXP items at /opt/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Storable.pm line 341, at /tmpfs/.cpan-build/Parallel-WorkUnit-1.001-uA3PDH/blib/lib/Parallel/WorkUnit.pm line 152.