标签:一个 container border comm print pad number spawn ble
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import gevent def foo(): print ( "Running in foo" ) gevent.sleep( 2 ) print ( "Explicit context switch to foo again" ) def bar(): print ( "Explicit context to bar" ) gevent.sleep( 1 ) print ( "Implicit context switch back to bar" ) def func3(): print ( "running func3" ) gevent.sleep( 0 ) #遇到io就切换,sleep最长2秒,所以整个程序花费两秒,如果是串行需要花费3秒 print ( "running func3 again" ) gevent.joinall([ gevent.spawn(foo), #启动一个协程 gevent.spawn(bar), gevent.spawn(func3) ] ) |
标签:一个 container border comm print pad number spawn ble
原文地址:https://www.cnblogs.com/394510636-ff/p/9282142.html