diff --git a/CHANGELOG.md b/CHANGELOG.md index bf063e4..a22b63b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,3 +140,7 @@ ## 4.1.0(2021-01-11) * 功能 - aio http session使用自定义timeout,可以和cache兼容使用(默认的timeout为什么不行,原因不明……); + +## 4.1.1(2021-01-16) +* bugfix + - 修复(workaround)win下结束爬取后报错的问题 diff --git a/src/__main__.py b/src/__main__.py index b2068ce..29a028e 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,3 +1,4 @@ +import sys import datetime from src.crawl import item_crawler @@ -6,6 +7,9 @@ if __name__ == '__main__': + if sys.version_info[:2] == (3, 7): + asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) + # start start = datetime.datetime.now() log.info("Start Time: {}".format(start)) diff --git a/src/crawl/item_crawler.py b/src/crawl/item_crawler.py index 44294ab..f624efa 100644 --- a/src/crawl/item_crawler.py +++ b/src/crawl/item_crawler.py @@ -1,6 +1,6 @@ import re -import asyncio import math +import asyncio # from tqdm import tqdm @@ -59,8 +59,7 @@ def csgo_all_categories(): def enrich_item_with_price_history(csgo_items, crawl_steam_async=True): # crawl price for all items if crawl_steam_async: - # asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - asyncio.run(history_price_crawler.async_crawl_history_price(csgo_items)) + asyncio.get_event_loop().run_until_complete(history_price_crawler.async_crawl_history_price(csgo_items)) else: history_price_crawler.crawl_history_price(csgo_items) return csgo_items