if name == "main": file = open("mssql.ip",'r') for ip in file.readlines(): ip = ip.strip('\n') t1 = Thread(target=content,args=(ip,)) t1.start() 写一个东西 目前是这么用的 怎么控制线程数量
1
pusidun 2018-03-11 16:07:39 +08:00
线程池
``` pip install threadpool ``` |
2
BBCCBB 2018-03-11 19:27:26 +08:00
```python
from multiprocessing.dummy import Pool as ThreadPool ``` |
3
matsuz 2018-03-11 21:36:43 +08:00 via iPhone 2
concurrent.future.ThreadPoolExecutor
|
4
jackqian 2018-03-11 22:16:07 +08:00 via iPhone
应该有类似 java 的线程池
|
5
hanbaobao2005 2018-03-12 09:47:11 +08:00
https://segmentfault.com/a/1190000000414339
from multiprocessing import Pool from multiprocessing.dummy import Pool as ThreadPool pool = ThreadPool() pool = ThreadPool(4) # Sets the pool size to 4 results = pool.map(func, paras) pool.close() pool.join() |
6
Mojy 2018-03-13 17:52:09 +08:00
@hanbaobao2005 这个应该是进程池吧?
|