Can be programmed in parallel
goless
# -*- coding: utf-8 -*-
import goless
import time
c1 = goless.chan()
c2 = goless.chan()
def func1():
time.sleep(1)
c1.send('one')
goless.go(func1)
def func2():
time.sleep(2)
c2.send('two')
goless.go(func2)
for i in range(2):
case, val = goless.select([goless.rcase(c1), goless.rcase(c2)])
print(val)
It is output at the same timing.
output
one
two
Recommended Posts