从python控制台执行时,Gevent start()方法不会启动新线程

时间:2018-07-24 08:57:42

标签: python pycharm gevent

从PyCharm控制台运行时,Gevent线程不会在调用start()方法时启动,只有在调用join()时才启动。 为什么?

Python 3.6.3 (default, Oct  4 2017, 06:09:38) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
import gevent
def dummy():
    for _ in range(10):
        print("Dummy!")
g = gevent.Greenlet(dummy)
g.start()

# Nothing happens ....

g.join()
Dummy!
Dummy!
Dummy!
Dummy!
Dummy!
Dummy!
Dummy!
Dummy!
Dummy!
Dummy!

0 个答案:

没有答案