scriptA.py 内容:
import shlex, subprocess
from dask.distributed import Client
def my_task(params):
print("params[1]", params[1]) ## prints python scriptB.py arg1 arg2
child = subprocess.Popen(shlex.split(params[1]), shell=False)
child.communicate()
if __name__ == '__main__':
clienta = Client("192.168.1.3:8786")
params=["dummy_arguments", "python scriptB.py arg1 arg2"]
future = clienta.submit(my_task, params)
print(future.result())
print("over.!")
scriptB.py 内容:
import file1, file2
from folder1 import file4
import time
for _ in range(3):
file1.do_something();
file4.try_something();
print("sleeping for 1 sec")
time.sleep(1)
print("waked up..")
scriptA.py 在 node-1(192.168.23.12:9784) 上运行,而 dask-worker 在另一个 node-2 (198.168.54.86:4658) 上运行,而 dask-scheduler 在不同的 node-3(198.168.1.3:8786) 上运行.
这里的问题是如何将 scriptB.py 所需的依赖项(例如 folder1、file1、file2 等)从运行在 node-1 上的 scriptA.py 传递给 dask-worker node-2。