文档上说stackless通道的receive函数,在这个通道send之前,会被阻塞。但是经测试,未被阻塞。
1 import stackless
2
3 ping_channel = stackless.channel()
4
5 def ping():
6 while True:
7 print ping_channel.receive()
8
9 stackless.tasklet(ping)()
10 stackless.tasklet(ping_channel.send)('I will block ping')
11 stackless.run()
终端上只打印了
I will block ping
然后程序就退出了
~$ python test.py
I will block ping
~$
如果注释掉第10行,则程序直接退出