1
$\begingroup$

I noticed this in V.10 but possibly it was in effect in V.9.

I have a package which in simplified form looks like:-

BeginPackage["Utilities`DataHandling`"];
f;
Begin["`Private`"];
f[data_List] := Module[{samples, selectFrom},
    selectFrom[]:=($KernelID->data);
    	DistributeDefinitions[selectFrom];
    	samples = ParallelTable[$KernelID->Apply[Hold,{"CTUDH",$Context, Context[selectFrom], selectFrom[]}], {10}, Method -> "CoarsestGrained"];
    samples
    ];
End[];
EndPackage[];

The actual package is much bigger and performed a useful function, the payload in ParallelTable here is to illustrate the problem.

When f is executed, the local symbol selectFrom is given a definition and distributed to all sub-kernels.

Except that its not (when the package is loaded via Needs). So far as the sub-kernels are concerned the symbol selectFrom has no definition so the call selectFrom results in Utilities`DataHandling`Private`selectFromXXX[] - the Hold prevents this from evaluating in the master kernel on return. Try f[{1,2,3}].

Changing the package name to MyUtilitiesDataHandling or indeed anything else resolves this and selectFrom is correctly defined in all the sub-kernels. This only took a day or so to work out *sigh*.

What is special about the (admittedly Built-in) context Utilities? How does it mess up DistributeDefintions?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.