因此,在通過pycharm運行時gevent升級到1.1rc4(從1.0.2)之後,我無法讓greenlet正確地加入......將此代碼例如:使用pycharm + gevent greenlet.join()不再阻止
from gevent import monkey, Greenlet, hub
import gevent
hub.Hub.resolver_class = ['gevent.resolver_ares.Resolver']
monkey.patch_all()
def sleepy(time):
gevent.sleep(time)
print "done like a good script"
if __name__ == '__main__':
g = gevent.spawn(sleepy,10)
g.start()
g.join()
print "if this is the only log line, then join didn't work"
將輸出:
"if this is the only log line, then join didn't work"
從IDE,它執行通常使用相同的解釋器從CLI
我按照在CLI和GUI和在那裏的代碼是不同的CE行爲greenlet.join()
在hub.switch()
造成行爲上的變化:
def switch(self):
switch_out = getattr(getcurrent(), 'switch_out', None)
if switch_out is not None:
switch_out()
return greenlet.switch(self)
其中最後一行,將執行greenlet之前立即返回,... 的pycharm調試器不會讓我步入代碼.. 。
任何幫助將是巨大的......協同程序的流量控制是夠硬時,它的工作原理...
其實pycharm的發佈昨天解決了這個問題。 –
好的,那是好消息。 – DevShark