LoginSignup
1
1

More than 5 years have passed since last update.

めざせpythonライブラリマスター (39)goless

Posted at

【ライブラリ説明】

 並行プログラミングができる

【プログラム】

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)

【結果】

一緒のタイミングで出力されます。

output
one
two

【参考サイト】

 pypi
 github

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1