84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
Assumption:
def get(url): #这里是get请求 return url for i in urls: get(i) #这里采用循环去调用请求 #这样速度好像比较慢,有什么方法可以 #当多个请求时,也可以快速完成程序
Thank you
学习是最好的投资!
>>> from eventor import Eventor >>> urllist = ["https://a.com", ....] >>> def get(url): # 网络IO耗时 return url >>> e = Eventor(threadcount=3, taskunitcount=3, func=get, interval=1) >>> result = e.run_with_tasklist(urllist) >>> print(result)
Choose multi-core, multi-process or multi-thread according to your needs, coroutines speed up processing.
Move details: https://github.com/kute/eventor
We will add async await, celery worker, etc. in the future
Several methods and can be used in combination
coroutine
multiprocess
multithread
celery worker
The simplest modification is to use multiprocessing.dummy to perform multi-threaded tasks. You can check it, set the number of threads, and then it can be used without much modification to the program.
Choose multi-core, multi-process or multi-thread according to your needs, coroutines speed up processing.
Move details: https://github.com/kute/eventor
We will add async await, celery worker, etc. in the future
Several methods and can be used in combination
coroutine
multiprocess
multithread
celery worker
The simplest modification is to use multiprocessing.dummy to perform multi-threaded tasks. You can check it, set the number of threads, and then it can be used without much modification to the program.