01 2018 档案
摘要:```
from threading import Thread,current_thread
from queue import Queue
import time class ThreadPool: def __init__(self,n): self.queue=Queue() for i in range(n):#在线程池里面开启n个线程 ...
阅读全文
摘要:```
#python自带的线程池
from multiprocessing.pool import ThreadPool #注意ThreadPool不在threading模块下
from multiprocessing import Pool #导入进程池 def func(*args,**kwargs): print(args,kwargs) pool=ThreadPool(2)
...
阅读全文
摘要:```
#使用池来实现并发服务器
import socket
from multiprocessing import cpu_count,Pool
from multiprocessing.pool import ThreadPool server=socket.socket()
server.bind(('0.0.0.0',8080))
server.listen(1000) def wo...
阅读全文
摘要:1.yum y install gcc 2.下载python3.5的安装包: wget https://www.python.org/ftp/python/3.5.2/Python 3.5.2.tgz 3.解压:tar zxvf Python 3.5.2.tgz 4.cd Python 3.5.2.
阅读全文