def client_proc(computation, task=None):
# schedule computation with the scheduler
if (yield computation.schedule()):
raise Exception('schedule failed')
i = 0
while True:
cmd = yield task.receive()
if cmd is None:
break
i += 1
c = C(i)
c.n = random.uniform(20, 50)
# unlike in dispycos_client*.py, here 'run_async' is used to run as
# many tasks as given on servers (i.e., possibly more than one
# task on a server at any time).
rtask = yield computation.run_async(compute, c, task)
if isinstance(rtask, pycos.Task):
print(' %s: rtask %s created' % (i, rtask))
else:
print(' %s: rtask failed: %s' % (i, rtask))
# unlike in dispycos_httpd1.py, here 'await_async' is not used, so any
# running async tasks are just terminated.
yield computation.close()
评论列表
文章目录