#Running scripts in parallel

run("Motor Test 3 100ms")

ret = parallelize((run,("Motor Test 3 100ms")), (run,("Motor Test 3 200ms")))
print ret




#Simple parallization
def task1():
    return 1

def task2():
    return 2

def task3():
    time.sleep(0.1)
    return 3

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
    return "OK"

ret = parallelize((devRead,(1,"1")), (devRead,(2,"2")), (devRead,(3,"3")))
print ret


#Exception in parallel task
def taskExcept(msg):
    raise Exception ("Error in parallel task " + msg)


ret = parallelize((taskExcept,("1")), (taskExcept,("2")) )
print ret


