Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
fix event loop is closed in win10 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccinv authored Jan 16, 2021
1 parent 0b1adfd commit 4eec549
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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下结束爬取后报错的问题
4 changes: 4 additions & 0 deletions src/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import datetime

from src.crawl import item_crawler
Expand All @@ -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))
Expand Down
5 changes: 2 additions & 3 deletions src/crawl/item_crawler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
import asyncio
import math
import asyncio

# from tqdm import tqdm

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4eec549

Please sign in to comment.