Closedown

This commit is contained in:
boccioli_m
2015-05-29 11:24:05 +02:00
parent 559271e820
commit 364def627b
24 changed files with 866 additions and 0 deletions

42
script/test/parallel.py Normal file
View File

@@ -0,0 +1,42 @@
#Simple parallization
def task1():
return out.read()
def task2():
return inp.read()
def task3():
time.sleep(0.1)
return sin.read()
ret = parallelize(task1, task2, task3)
print ret
#Fork amd join
ret = fork(task1, task2, task3)
time.sleep(0.1)
ret = join(ret)
print ret
#Functions with parameters
def devRead(dev, msg):
print msg + " -> " + dev.getName()
return dev.read()
ret = parallelize((devRead,(out,"1")), (devRead,(inp,"2")), (devRead,(sin,"3")))
print ret
#Exception in parallel task
def taskExcept(msg):
raise Exception ("Error in parallel task " + msg)
ret = parallelize((taskExcept,("1")), (taskExcept,(inp,"2")) )
print ret