我有一个简单的宏
macro lit_str(s)
s
end
我用它来生成正则表达式模式。 (上下文here)。通常我将其包装在一个名为 HelperFunctions 的模块中(并使用 ```export @lit_str 导出它)。我试图在通过 RemoteRef 调用的函数中使用它,但即使我这样做
@everywhere 使用 HelperFunctions
我收到类似的错误
exception on exception on 3: exception on 2: 4: ERROR: @lit_str not defined
in eval at C:\cygwin\home\vagrant\buildbot\slave\package_win8_1-x64\build\base\sysimg.jl:7
in anonymous at multi.jl:1305
in anonymous at multi.jl:855
in run_work_thunk at multi.jl:621
in anonymous at task.jl:855
ERROR: @lit_str not defined
in eval at C:\cygwin\home\vagrant\buildbot\slave\package_win8_1-x64\build\base\sysimg.jl:7
in anonymous at multi.jl:1305
in anonymous at multi.jl:855
in run_work_thunk at multi.jl:621
in anonymous at task.jl:855
ERROR: @lit_str not defined
in eval at C:\cygwin\home\vagrant\buildbot\slave\package_win8_1-x64\build\base\sysimg.jl:7
in anonymous at multi.jl:1305
in anonymous at multi.jl:855
in run_work_thunk at multi.jl:621
in anonymous at task.jl:855
有什么方法可以导出宏,以便它可以由由 Remoteref 生成的进程使用吗?
最佳答案
这是显而易见的,但我会将解决方案放在这里,以防其他人遇到同样的问题。我需要做
addprocs(numprocs)
之前
@everywhere using WhatNot
因为我是在 Jupyter 中执行此操作,而不是通过调用 julia -p 8 myfile.jl
。
关于parallel-processing - 如何在 Julia 中到处定义宏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31948930/