-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Fetch with limited concurrency #47
Draft
YDX-2147483647
wants to merge
9
commits into
main
Choose a base branch
from
p-map
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+60
−12
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- `fetch_all_sources`时,不再一下子发起所有请求,而一点一点发起,限制并发数量上限。 - 配置文件新增`fetch_concurrency: number`。 Resolves #45
服务器上还是不太行呢。 $ npm run update-server
> [email protected] update-server
> node dist/examples/server-cli.js
info: Signed in successfully.(proxy)
抓取通知 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% | 0/48 | 已用0s,预计还需0s
info: 发现48个通知来源。(cli)
抓取通知 ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 10% | 5/48 | 已用2m11s,预计还需9s
error: 访问“特立”(ETIMEDOUT)超时,可
抓取通知 █████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 12% | 6/48 | 已用2m11s,预计还需15m20s
error: 访问“马克思”(ETIMEDOUT)超
error: 访问“知艺”(ETIMEDOUT)超时,可能因为访问太频繁。将忽略。(cli)
error: 访问“留学生”(ETIMEDOUT)超时,可能因为访问太频繁。将忽略。(cli)
error: 访问“北京书院”(ETIMEDOUT)超时,可能因为访问太频繁。将忽略。(cli)
抓取通知 ███████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 27% | 13/48 | 已用2m33s,预计还需8m60s
warn: 未从“创新创业”获取到任何通知
抓取通知 ███████████████░░░░░░░░░░░░░░░░░░░░░░░░░ 37% | 18/48 | 已用4m22s,预计还需3m40s
error: 访问“教学中心”(ETIMEDOUT)
抓取通知 ████████████████░░░░░░░░░░░░░░░░░░░░░░░░ 39% | 19/48 | 已用4m22s,预计还需7m5s
error: 访问“计算机”(ETIMEDOUT)超时
error: 访问“教务部”(ETIMEDOUT)超时,可能因为访问太频繁。将忽略。(cli)
抓取通知 ██████████████████░░░░░░░░░░░░░░░░░░░░░░ 43% | 21/48 | 已用4m45s,预计还需6m10s
error: 访问“光电”(ETIMEDOUT)超时
抓取通知 ███████████████████░░░░░░░░░░░░░░░░░░░░░ 47% | 23/48 | 已用5m28s,预计还需6m30s
error: 访问“网信”(ETIMEDOUT)超时
抓取通知 ██████████████████████░░░░░░░░░░░░░░░░░░ 54% | 26/48 | 已用6m56s,预计还需7m5s
error: 访问“校医院”(ETIMEDOUT)超时
抓取通知 ███████████████████████░░░░░░░░░░░░░░░░░ 58% | 28/48 | 已用7m4s,预计还需5m40s
error: 访问“国际交流”(ETIMEDOUT)超
抓取通知 ████████████████████████░░░░░░░░░░░░░░░░ 60% | 29/48 | 已用7m39s,预计还需5m40s
error: 访问“网安”(ETIMEDOUT)超时
抓取通知 █████████████████████████░░░░░░░░░░░░░░░ 62% | 30/48 | 已用7m39s,预计还需6m35s
error: 访问“信电”(ETIMEDOUT)超时
error: 访问“新生”(ETIMEDOUT)超时,可能因为访问太频繁。将忽略。(cli)
抓取通知 ███████████████████████████░░░░░░░░░░░░░ 66% | 32/48 | 已用9m5s,预计还需4m55s 串行也不行: $ npm run update-server
> [email protected] update-server
> node dist/examples/server-cli.js
info: Signed in successfully.(proxy)
抓取通知 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% | 0/48 | 已用0s,预计还需0s
info: 发现48个通知来源。(cli)
抓取通知 ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 8% | 4/48 | 已用2m57s,预计还需8m20s
error: 访问“经管”(ETIMEDOUT)超时,
抓取通知 ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 20% | 10/48 | 已用5m11s,预计还需16m55s 下一步计划往 |
等十秒还是有两个来源超时。二十秒也是。 @@ -1,3 +1,4 @@
+import { setTimeout } from 'node:timers/promises'
import pMap from 'p-map'
import type { HookCollectionType } from '../hooks_type.js'
@@ -28,6 +29,8 @@ export async function fetch_all_sources ({
// First create a non-hook version.
async function fetch_each ({ source }: { source: Source }): Promise<{ notices: Notice[] }> {
const notices = await source.fetch_notice({ _hook })
+ // Sleep for 10 seconds
+ await setTimeout(10000)
return { notices }
} |
- 配置`fetch_concurrency`更改为`fetch.concurrency`。 - 新增配置`fetch.sleep`。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fetch_all_sources
时,不再一下子发起所有请求,而一点一点发起,限制并发数量上限。fetch: { concurrency: number, sleep: number }
。Resolves #45