I want to use LocalSubmit to create continuous tasks that run in parallel. But it not works with functions from packages. For example:


func1[] := "function 1"

EndPackage[]; (*pack1`*)



func2[] := LocalSubmit[func1[] >> "test.txt"]

EndPackage[]; (*pack2`*)

And if I run this code:


the following is written to the file test.txt:


I know how this problem can be resolved if packages in files pack1.m and pack2.m. func2 must be defined as follows:

func2[] := LocalSubmit[Get["pack1`"]; func1[] >> "test.txt"]

There may be a better solution that saves the functions from the loaded contexts??


1 Answer 1


I don't know how the 'separate kernel' is handled, whether it is killed after or will be reused but in case of the latter I'd expose needed package on $Path and add Needs["pack1`"] etc.

Alternatively you can embed needed definitions similarly to how they are embedded in APIFunctions and friends:


func2[] := LocalSubmit[
    Language`ExtendedFullDefinition[] = #; func1[] >> "test.txt"
] &@Language`ExtendedFullDefinition[func1]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.