Giter Club home page Giter Club logo

Comments (3)

liangjianfeng-av avatar liangjianfeng-av commented on August 19, 2024

我觉得是有必要做线程上限分批处理的。
比如分每50~100张做一个最大线程控制。比如总数500页,分5次,每次100。
A 在网络通畅以及cpu没压力的情况下,每次100可以快速完成。分开5次的时间,实际上并不比一次500多多少。
B 在网络不通畅(包括限流等情况),每次100或者可以避免被限流,耗费时间必定增加却能提高成功率,但是一次500就很可能就卡在那里了,只能手动停止程序重新连接,实际耗费时间更多。
C 由用户自己选择线程数?每次启动询问线程数?现阶段感觉没必要。
另外,我复制了你修改后的代码,运行出错,估计是我哪里搞错了,请帮忙指导,谢谢。^-^

错误如下:

Traceback (most recent call last):
File "H:\新建文件夹\Catch18comic-3.py", line 251, in
main(mirror, id)
File "H:\新建文件夹\Catch18comic-3.py", line 210, in main
while ERROR_PAGE_LIST:
UnboundLocalError: local variable 'ERROR_PAGE_LIST' referenced before assignment

from 18comic-download.

maoyj avatar maoyj commented on August 19, 2024

我觉得是有必要做线程上限分批处理的。
比如分每50~100张做一个最大线程控制。比如总数500页,分5次,每次100。
A 在网络通畅以及cpu没压力的情况下,每次100可以快速完成。分开5次的时间,实际上并不比一次500多多少。
B 在网络不通畅(包括限流等情况),每次100或者可以避免被限流,耗费时间必定增加却能提高成功率,但是一次500就很可能就卡在那里了,只能手动停止程序重新连接,实际耗费时间更多。
C 由用户自己选择线程数?每次启动询问线程数?现阶段感觉没必要。
另外,我复制了你修改后的代码,运行出错,估计是我哪里搞错了,请帮忙指导,谢谢。^-^

错误如下:

Traceback (most recent call last):
File "H:\新建文件夹\Catch18comic-3.py", line 251, in
main(mirror, id)
File "H:\新建文件夹\Catch18comic-3.py", line 210, in main
while ERROR_PAGE_LIST:
UnboundLocalError: local variable 'ERROR_PAGE_LIST' referenced before assignment

抱歉,我没有用git程序,是手动通过网页把改动更新到github上的,所以产生了错误。
经过测试,我本地的文件可以顺利运行,而从网页复制的代码出现了一样的故障。其中的差异已经找到

原因在于原来的main()里面不修改ERROR_PAGE_LIST,所以不声明全局变量也可以。我后来加上了ERROR_PAGE_LIST去重的操作,却没有声明全局变量,所以出现了这个问题。而我本地的文件因为后来加入了WARNING_PAGE_LIST所以不需要去重操作已经删掉了那句。

另外,针对我版本的问题可以直接到我fork的里面提issue,这个是我没有测试好就push的责任。

from 18comic-download.

maoyj avatar maoyj commented on August 19, 2024

试了一下,原来几百个线程的下载速度在8M
限定30个线程的话速度在3M。
自动重连和异常捕获也有了,下载部分差不多就这样,暂时没什么要改进的了。

主要下载变好了,身体遭不住了。

from 18comic-download.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.