def setup_server(data_file, task=None): # executed on remote server
# variables declared as 'global' will be available in tasks for read/write
# to all computations on a server.
global hashlib, data, file_name
import os, hashlib
file_name = data_file
print('%s processing %s' % (task.location, data_file))
# note that files transferred to server are in the directory where
# computations are executed (cf 'node_setup' in dispycos_client9_node.py)
with open(data_file, 'rb') as fd:
data = fd.read()
os.remove(data_file) # data_file is not needed anymore
# generator functions must have at least one 'yield'
yield 0 # indicate successful initialization with exit value 0
# 'compute' is executed at remote server process repeatedly to compute checksum
# of data in memory, initialized by 'setup_server'
评论列表
文章目录