def node_setup(data_file):
# 'node_setup' is executed on a node with the arguments returned by
# 'node_available'. This task should return 0 to indicate successful
# initialization.
# variables declared as 'global' will be available (as read-only) in tasks.
global os, hashlib, data, file_name
import os, hashlib
# note that files transferred to node are in parent directory of cwd where
# each computation is run (in case such files need to be accessed in
# computation).
print('data_file: "%s"' % data_file)
with open(data_file, 'rb') as fd:
data = fd.read()
os.remove(data_file) # data_file is not needed anymore
file_name = data_file
yield 0 # task must have at least one 'yield' and 0 indicates success
# 'compute' is executed at remote server process repeatedly to compute checksum
# of data in memory, initialized by 'node_setup'
评论列表
文章目录