Ipython console中monkey.patch_all()出错
代码如下:
from gevent import monkey
monkey.patch_all()
import gevent
import urllib
def run_task(url):
print('Visit --> %s' % url)
try:
response = urllib.request.urlopen(url)
data = response.read()
print('%d bytes received from %s.' % (len(data), url))
except Exception as e:
print(e)
if __name__ == '__main__':
urls = ['https://github.com/', 'https://www.python.org/',
'http://www.zuel.edu.cn/']
greenlets = [gevent.spawn(run_task, url) for url in urls]
gevent.joinall(greenlets)
python3,使用spyder中的Ipython console 运行会抛出警告:
The history saving thread hit an unexpected error (LoopExit('This operation would block forever', <Hub at 0xbd6caf8 select pending=0 ref=0>)).History will not be written to the database.
然后程序一直无法终止(网络没问题,可以urlopen),请大神指教。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论