与gevent脚本没有完成

时间:2016-04-05 12:52:24

标签: python xlsx gevent

问题是当脚本完成时它没有像这样编写"处理完成了退出代码1"。但打印("退出......")正在运行。问题是什么?

from gevent import monkey
import gevent

monkey.patch_all()

threads_count = 2
urls_dic = {}
for filename in search_term:
    if os.path.isfile(filename):
        urls_dic[filename] = []
        f = open(filename, mode='r')
        for line in f:
            urls_dic[filename].append(line.strip())
        f.close()
new_urls = []
for i in range(threads_count):
    new_urls.insert(i, {})
    for key in urls_dic:
        new_urls[i][key] = []
        for url in range(i, len(urls_dic[key]), threads_count):
            new_urls[i][key].append(urls_dic[key][url])
threads = [gevent.spawn(start, new_urls[i], i + 1) for i in range(threads_count)]
gevent.joinall(threads)
for job in threads:
    print("job=", job)
    for key in job.value:
        write_excel(job.value[key], key)
print("exiting")
exit(1)

0 个答案:

没有答案