本节内容:

线程:

a:基本的使用:

创建线程:

1:方法

 import threading

 def  f1(x):
print(x) if __name__=='__main__':
t=threading.Thread(target=f1,args=(,))
t.start()

t=threading.Thread(target=f1,args=(1,))创建线程,target=动作(执行什么,需要是可被调用的函数)args参数元组,要求参数最后加个逗号。

当我们创建一个线程时候,t.start()之后,线程已经准备就绪等待cpu调度。

cpu通过触发threading.Thread类中的run方法来调用我们传入的target 函数。通过debug断点调试可以看到如下:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdAAAADNCAIAAACHALamAAAgAElEQVR4nO2daVAb55rv+/utmakzU3O/ZKpOpuYMO+QwOMfmJPFJjuPEDpjNbMICg1nsOAESwHZi49h4ARIb7NiAJDCbAJs1GDvgmH2RBAKEQWK3hFmMkX3qpG6u61a55t4q3Q8ttVqtVqu1tWjx/OtXWLzqXfKPR2+3+kU8Pby9PL2Fwrq33357XLEBAAAAOAjE08PLw8Ortlb49u+3l3CHZM/iC3/66+nafWeE+84I952pPfp9+8DEitM3DAAAwDoQD5xwpfL17UNRs+TghUapfD38+/bD1zoifrgfdKn5epPY6RsGAABgHYiHh5eHu1dtrfD320y4V++OBOe3hRS2Hy7+Ofb2LzG3HoVfe3CpfsjpGwYAAGAdiIe7l4e7JyrcsZk16xidrg1FOMXTq1YvAePx6NLVusGrdYMF90auNIqvNolz60ciin8+fKMz9IeOS3UDyxOnlsa/nZyW2r4uAAAAJkE83D3ddcIdnV7FI3lSE4ro45s9QJjAcEpO8ZNnpiagT/iFe+/lVO/9RvjX3Lv7LzZ9eqnl4NW24O/vh1x78Fn+TxeF3b/O/fHXuT9uyqPoLK04AkHeOd9MtmHN2QFIRI3xZMURVHsKAABgNYi7GeFqNSp5MpD5DoIZimJKG3nvdO2+i037L7WgfHK55dMrrQfyfzpY0L7/Usvt1s6/y9/5u+KdV1M+1MuRdJz3RZDQCA6pcCUd533fOd/85JnxZJInA5nvBGR22GFfAAAA8BgIV/LkGR7xVE0oEls0taL7tT/TDwktWZE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3r9H9OOAwAARLNYRSzrvfLHtOMAAADRLFIRAQAATg6KCAAAIASKCAAAIEERAQAAhEARAQAAJCgiAACAECgiAACABEUEAAAQAkUEAACQoIgAAABCoIgAAAASFBEAAE7Nizt3Ro+kZgifEnM6iggAAKfmEEV8ceeOnZz51Y/kH+FaUEQAADg1qYoYP0H0yaQhjU5QRAAAODVJijhhvdQ+C0UEAIAF4VztDC+BxiiZr67AP52giAAAcGoCc0SfdMVImvMRoy/Zp6OIAAA3xy/ffffLDz+c0YBURQy/VuNUOOaIAAAwwsu6/uV//ue8NthvfgYUMfA26WgVzn/6TlyiIm7XebZujloFAMAN8ss33/z80UfnnR1KAt+LcCrZZEV0Fntpiriqd0etAwDgxvj5o49+/uMfz22FEK45ny2Qxt/TFDG+KMnSFLFZZ3mWFUOS0rirV/L4utltyiwrsqy8/02fudzslDxZtZWF7TarLMuy9fZo5gIALJ+XT548f+utl3V9bkMGlZr8HHH0oFHR6EGVpSmiEP454nY9CN5uU2brRmyrLCtWm72SoRr0D0UEgNvmlx9+ePHOO8/feuuXb745ty0agaXRAxUxRnR9516cIlZb38FdvcryXh0BAG6cl3X9/LXXXvzzPy/hwaHBqCLGvCk64c2a8Ez00hTRfuOmE0KnXgIA3CC/fPfdi9/+9sWdOz//27+d2xY3genaMRTR/vsSFXG/WeXaoqjrHdRuNbUwJ4ismgLA7fHzv//789dee/6rX7188uTctjiImasFfrnGWUigiqQHiktURO39GimN20p73SYrNGls36mxJogoIgDcEr98883zf/zHF3fuPH/rrV8W/MXxmNc+R+eISUumkRmWqYiJ8AQRAG6bX3744ef33mt/veWdd85tzqVyDYrIE0QAuGVePnny/Ne/lnL48uHDc5tzwVy0IlqLqwAAt8QvP/zw4l/+RWrh81//emlfsbg4LloRAQBul5cPHz5/7bV2pfS3v13gVywuDhQRAODC6L9cIdNCfpstlZj3a5z548+KLLlniYlql7QAABcWSURBVIqI4gIA+Pj5o496LXz+q18t4bfZphHz09u+/JGnxGeToIgAAEvk5ZMnh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CgRDxgHgzzD4B64XFBEAAECIaYoIAABwfaCIAAAAQqCIAAAAEhQRAABACBQRAABAgiICAAAIgSICAABIUEQAAAAhUEQAAAAJiggAACAEiggAACBBEQEAAIRAEQEAACQoIgAAgBAoIgAAgARFBAAAEAJFBAAAkKCIAAAAQqCIAAAAkv8PZH3M/coyc7MAAAAASUVORK5CYII=" alt="" />

所以我们可以自定义咱们自己的run方法,来被cpu调度。

2:方法

 import  threading

 class myclass(threading.Thread):

     def __init__(self,x):
super().__init__()
self.x=x def run(self):
print(self.x) if __name__=='__main__':
obj=myclass()
obj.start()

通过我们自定义run方法来覆盖父类中的run方法。

并通过start方法 来让cpu调度我们的线程obj。

如上2个方法的本质是相同的。都是cpu的调度run方法实现。

对比1和2方法,1方法是我们常用的。不推荐第二种方法。

b:队列 queue

 import queue

 q=queue.Queue()##先进先出的队列
q.put()#往队列里放数据。
q.put()
q.put()
print(q.qsize())#队列的长度
print(q.get())#队列取数据。
print(q.qsize())
 import queue

 q=queue.Queue()##先进先出的队列,可以设置队列的长度,默认是没限制。
q.put()#往队列里放数据。
q.put()
print(q.qsize())
q.put(,timeout=)#当队列的数据满了之后,在往里放数据会阻塞,等待队列长度改变。可以设置超时间。超时时间之后,队列的长度没改变,会报错。
print(q.qsize())#队列的长度
print(q.get())#队列取数据。
print(q.qsize()) Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/S12/day11/s3.py", line , in <module>
q.put(,timeout=)#当队列的数据满了之后,在往里放数据会阻塞,等待队列长度改变。可以设置超时间。
File "E:\python3.6\lib\queue.py", line , in put
raise Full
queue.Full

也可以设置放数据不阻塞。参数问block=False 默认该参数是True

 import queue

 q=queue.Queue()##先进先出的队列,可以设置队列的长度,默认是没限制。
q.put()#往队列里放数据。
q.put()
print(q.qsize())
q.put(,block=False)##设置队列不阻塞。
print(q.qsize())#队列的长度

get同样也有这些方法。超时、是否阻塞。

 import queue

 q=queue.Queue()##先进先出的队列,可以设置队列的长度,默认是没限制。
q.put()#往队列里放数据。
q.put()
print(q.get())
print(q.get())#队列取数据。如果队列为空的时候获取数据的话,会阻塞。和get方法一样也可以设置超时间、是否阻塞。
print(q.get(timeout=))
print(q.qsize()) Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/S12/day11/s4.py", line , in <module>
print(q.get(timeout=))
File "E:\python3.6\lib\queue.py", line , in get
raise Empty
queue.Empty
 import queue

 q=queue.Queue()##先进先出的队列,可以设置队列的长度,默认是没限制。
q.put()#往队列里放数据。
q.put()
print(q.get())
print(q.get())#队列取数据。如果队列为空的时候获取数据的话,会阻塞。和get方法一样也可以设置超时间、是否阻塞。
print(q.get(block=False))
print(q.qsize())

其他方法:join和task_done组合使用。

 import queue
q=queue.Queue()
q.put()
q.task_done()# 需要在每次取数据的时候告诉队列,这个数据已经完成了。是每次。这样join就不会阻塞了。
q.put()
q.task_done()
q.join()##当队列中有任务的时候,没做处理。该方法会阻塞,知道队列里的任务完成。可以配合task_done方法使用

需要注意:每次取数据需要使用task_done方法来告诉队列这个数据已经完成。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAAE3CAIAAADTwbGrAAAZt0lEQVR4nO2d7W8bx53H91+5v0BvKOD44g5F3hxwr4VzCh2Ee2HoxR0Oh+JQAr1eatVs4ofYTFw5VmLZ8YOayIIsOX4g5QfFiWvVNYHGrk3FZmVfa8uiHHAkyo0lJ6kp8F4suTuzO7PcnZ3dnR/3t/i8kERydpb8aGaXnC9/BmnVwvD0h9V3btRmHm199n+vuMw82nrnRu3pD6vux9aXRvoNa8vkl1ZCdgbRmdXV1S0f2/j4+At2M0irduHShRneduHi+a47nv3TNx/dacw8ejXz6NWn98nO3C//8UdvmJh/nHn06qM7jenqc8cD66VB2kvT16ESatqzhHL0Ya3CdfRhrdJ1x/sXalPVzemlremlrX/7yc//58in5s80U9XNfTeZR9VbE0MuI+ulQcMYPNNCTXuTUI6SVm3uaskh6NzVkp8d75pfOfOnLZM3/umfP33wV+tXmrfmXTpmR8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V7wsPA0xHpTJ3xL2IiVlizAlsOKu6mPEdThjNK/4heAg/ExdFZg06IB2Vzdw51pbTi3nZJIb7L0xFGK+AW8hMXBRZC+jAdFQuc+eIHLGFiJgUG+sZE3jihtHUZeLwlNQNSEclM3cCR9u/0ik2ZxiXFc4z4MZpLUgmDsdRNyAdlc3c0YXbzLKC7bnemWITp0O7h9HCZeKiyKxBB6SjRCpzR5hpN5Mv2MObI8VGheLZSdq+1ZkbUZKJI3hdzwOqoyR45s4BdwqWRk0mDk9GeQB2lATM3DlQ6yhRkYnDz5m4wHY0DModRSIivY4iUEBHEd1BRxHdQUcR3UFHEd1BRxHdge0oZu7SAGBHMXOXEqA6Gk+dO4mv2kv2o4GejPKBdDS2Onc6OIpRPpCOymXuZIRL2lGM8hGgjspl7iA6ilE+AtXR4Jk7Jm0nqElA3OE7R5Ekakmoywxqc+ZG3Pm7LmXyMMoH3tEwde7sdfjiGnPuh9RLg4bgWyGEUT5B5TtxmTyM8vWSoyrq3BHOqOmKy9nlcoQvsDDKJ6p8JypBxm4Y5YPtaPg6d9wac/Td2nG5duwp4/HVOkEc5Q6ZvnJ5nL6lJsoH0tEwde7ctQbpGnOuuBydwvMqccuJ8gkq33mUycMoX+84SmQzd1Ydt9utm+4ac8QdvnOVJ+RO+qIon9c1k7tMHkb5esxREjpzBwKM8hHQjpJwmTs54i97h1E+2I4iaQAdRXQHHUV0Bx1FdAcdRXQHHUV0R9rR/we06NAUECCjgAAAAABJRU5ErkJggg==" alt="" />

qsize,查看当前队列的长度。

get_nowait()实际上调用get(bliock=Flase)

put_nowait()也是调用put(block=Flase)

full()该方法表示检查当前队列是否满,返回是布尔值。

empty()该方法检查当前队列是否空,返回是布尔值。

 import  queue
q=queue.Queue()#构造方法中maxsize表示队列最大的长度。
q.put()
q.put()
print(q.qsize())## 查看当前队列长度。
print(q.empty())
print(q.full()) False
True

如上的队列是进程在内存里的队列,在python退出的时候队列也清空。

其他队列:如下队列都是queue的基础上操作的,继承queue这个类(除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0iDAEABqXHMHQpWxxQGFosZk+bEaDmiR9hWEh9abFYrB+GpAizWEzHS8KQ4T5WNZfv/LbmcJsMAHAAGBla28WTamRoWazZcBiaTUZLw5DlVpfv/JtFGAIADAphaBXi7bA2DC0WF6d3Hd+N9wtD1cCLNDajZBhxZKiKEeIDQdJtNbVur/k3izAEABgUwtAqmqentXth7e0z4RlqaaL4FtcD1KYwJDw/HUXj8bgZyGlvWY0mk7HwPvENwjPRvvNvFGEIADAofYUhm62t2AC/Wr9p0/FW7mptHGEIADAo/DmO/bXHYUh92JpfoAYA7A5haC+1d7P2Mw8BADAchCEAABA0whAAAAjawYYhAACALghDAAAgaIQhAAAQNMIQAAAIGmEIAAAEjTAEAACCRhgCAABBIwwBAICgEYYAAEDQ/h/AtUkBCEp8hwAAAABJRU5ErkJggg==" alt="" />

先进后出队列:

 import queue

 q=queue.LifoQueue()##先进后出队列。first in last out
q.put()
q.put()
q.put()
print(q.get())

优先级队列,包含2个参数一个数据,一个是权重值。

 import queue
q=queue.PriorityQueue()##权重优先队列,权重值越大,优先级越低。如果权重值一样,取第一个值。
q.put((,))
q.put((,))
q.put((,))
q.put((,))
print(q.get())
(, )

双向队列:可以在队列的两边进行数据的输入和输出。

 import queue
q=queue.deque()#双向队列,可以在2边进行取数据和放数据。很多方法和列表类似。
q.append()
q.appendleft()
print(q.pop())
print(q.popleft())

c:消费者和生产者模型:

主要解决了什么?

1:解决程序的阻塞问题。变相提高程序的处理效率和并发。

2:降低程序之间的解耦性。在修改任意一方的程序的时候,减少彼此的影响。

通过什么来实现?

可以通过消息队列,来实现中间的转换过程。

比如一个网站,在客户端同时有大并发的请求时候,可以通过应用程序来获取客户端的请求,并把请求放在消息队列中(这个操作很短,不容易出现阻塞情况。),此时客户端的请求,断开,应用程序把客户端的自动转发到另一个查询页面,这个页面

自动刷新,客户端请求的结果。后端程序在从消息队列中获取客户端的请求,进行处理,并更新数据库信息。当数据库更新成功之后,客户端查询就会显示结果。

好处:

1:降低了程序之间的耦合。

2:一个web请求,到达服务器之后,有后台程序进行处理。如果处理的时间过长,那么这个进程会被挂起,应用服务器会维护这个进程。如果大并发的请求,那么服务端会挂起较多进程,那么服务器会较多的资源浪费,而服务器也会出现hang死或者无效的请求,

因为一个sokcet维护的等待队列是有限,nginx的最大连接也是有限的。而这个模型很好的解决这个问题,他把客户端请求和后台程序处理请求分开。如果客户端请求过多,消息积压,后端可以提高服务器的数量来提高并发,而且这个后台应用程序不会维护客户端连接,

后台程序直接进行有效的请求处理,然后更新数据库,用户只需要查询数据库来验证自己的请求。

 import queue
import threading
import time
q=queue.Queue()
def productor(j):
while True:
print('the server %s deal request'%j,q.get())#队列获取消息。
time.sleep() def consumer(i):
q.put(' client NO:%s request'%i)#往队列中放消息。 for i in range():#后台3个程序在处理这个请求。
t=threading.Thread(target=productor,args=(i,))
t.start()
for j in range():
t=threading.Thread(target=consumer,args=(j,))##40个客户端请求。
t.start() the server deal request client NO: request
the server deal request client NO: request
the server deal request client NO: request
the server deal request client NO: request
the server deal request client NO: request
the server deal request client NO: request
......

d:线程锁:

线程是程序运行的最小单位,有时被称为轻量级进程(Lightweight Process,LWP),是程序执行流最小单元。一个标准线程是由线程ID,当前指令指针(pc),寄存器集合和堆栈组合,另外线程是进程的一个实体,是被系统独立调度和分派的基本单位。

线程不拥有系统资源,只拥有一点儿在运行中必不可少的资源,但它可与同属一个进程的其他线程共享所拥有的全部资源。一个线程可以创建和撤销另一个线程,同一个进程中的多个线程可以并发执行。由于线程之间的互相制约,致使线程在运行中呈现出间断性。

线程也有就绪、阻塞和运行的三种基本状态。就绪状态是指线程具备运行的所有条件,逻辑上可以运行,等待处理。运行状态是指线程占有cpu正在运行,阻塞状态是指线程在等待一个事件(如某个信号量),逻辑上不可执行。每个程序至少有一个线程,称为主线程。

在单个程序中同时运行多个线程完成不同工作,称为多线程。

基于线程和他的同一个进程所属的其他的线程共享资源,所以会出现以下情况:在多个线程共同对同一个数据进行修改的时候,会出现数据的不一致。

 import threading
import time
x=
def f1(): global x
x -=
time.sleep()
print(x) for i in range():
t=threading.Thread(target=f1)
t.start() .......

a:如上所示当多个线程对同一份数据进行修改的话,会出现数据混乱,并不是我们想要的数据。

避免多个线程对同一份数据同一时间进行修改,出现了互斥锁。

互斥锁:当一个线程在对数据进行修改的时候,如果加上互斥锁,只有当前线程执行的“动作”结束之后,下一个线程才可以进行相应的动作。

如下是只允许一个线程加锁和解锁。

 import threading
import time
x=
q=threading.RLock()
def f1(): global x
q.acquire()#加锁。递归锁
x -=
time.sleep()
q.release()#解锁。 print(x) for i in range():
t=threading.Thread(target=f1)
t.start()

互斥锁有一次性锁和递归锁(可以锁多次)。上面用的是递归锁,可以锁多层。我们一般用递归锁。如下是一次性锁。

 import threading
import time
x=
q=threading.Lock()#一次性锁。
def f1(l): global x
l.acquire()#上锁。
x -=
time.sleep()
l.release()#开锁。 print(x) for i in range():
t=threading.Thread(target=f1,args=(q,))
t.start()

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWQAAAHrCAIAAAB3n3B6AAAgAElEQVR4nO3d+1eU9b7A8fMHnbXO2g9ewhteAGUDBRoiiooXEvAK3tO2pgc1TVI0b3lNbXsyd5ZUnm2klpJiiphmiohkiAmMwFTKLF1zfnjOnjNnYPDxWz7P58v3Peu1WsMwDJ8Zvt+3Mw+j/ZvPHwCAZ/o3zycAoAViAcARYgHAEWIBwBFiAcARYgHAEWIBwBFiAcARYgHAEWIBwBFiAcARYgHAEWIBwBFiAcARYgHAEWIBwBFiAcARYgHAEWIBwBFiAcARYgHAEWIBwBFiAcARYgHAEWLhHsuyLMvyfAxADbFwD7HgodMasXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5pAypzINsXCPFite5p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19/47/Kvm9se1/38wL5w+cpVk6bkJqekHjh0xOcPZIweU33tVvgLHDmvQXzEwk2e/7D1HdLbWER82PnCvyan9OnTt3jNuq8rvhswYEDlpas+f+CnxpZhw+JPfnM+/MrffHvxtbyCgumzfP5AU+ujZW8WW5a1fsPmmjv3RmWM3lC6pfPtd3mJJ4iFe2TuQy2G9GSqG7d/jomJiRjD11UsmlofNbc9/udX3wwYOHD/B4dDnzp67PjgwUPKT3/r8wf+u/zrCRMnDR+RtHvfBw2/tO7e90FySuq48RPHZI0blz3h7ZLSVzMyw79L5+/rOWLhHpn7UIsh3Z9qUFxc79698wpmRIzhi/J0w+cPTMuffvDQkYjb2b3vA/t5xLjsCdt37Xvw8Hf7mnkFM//51Tc+f+D23V9yJk3p33/Awf86EvFdop28+ikQC/fI3IdaDClzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseJlDilzKtMQC/doseKFDHm9pt7q9nS9pt7zIU1DLNwjZB/qMmTW2Oxopcgam+35eAYiFu6Rsw+1GHLrjl3RYrFtx27PxzMQsXCPnH2oxZBXb9RFi8W1m3c8H89AxMI9cvZhOMlHBzJGZ3aeZ3TmGM8fNDMRC/fIjIVP8NGB0ne3dR6p9N1tnj9iZiIW7hEbC7FHB6q+v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AyYmEWYgFlxMIsxALKiIVZiAWUEQuzEAsoIxZmIRZQRizMQiygjFiYhVhAGbEwC7GAMmJhFmIBZcTCLMQCyoiFWYgFlBELsxALKCMWZiEWUEYszEIsoIxYmIVYQBmxMAuxgDJiYRZiAWXEwizEAsqIhVmIBZQRC7MQCygjFmYhFlBGLMxCLKCMWJiFWEAZsTALsYAyYmEWYgFlxMIsxALKiIVZiAWUEQuzEAsoIxZmIRZQRizMQiygjFj0cNdr6q1uT9dr6j0fElogFj1f1tjsaKXIGpvt+XjQBbHo+bbu2BUtFtt27PZ8POiCWPR8V2/URYvFtZt3PB8PuiAWRsgYndm5FKMzx3g+GDRCLIxQ+u62zrEofXeb54NBI8TCCFXf3+gci8tXb3o+GDRCLEzxSlp6eCnS0kd6PhL0QixMsf6d0vBYlGzY7PlI0AuxMEXlpavhsai8dNXzkaAXYmGKlvaO5JRUuxTJKakt7cVNu8kAAACESURBVB2ejwS9EAuDrF673o7FmrUlng8D7RALg5w9f8mORUVllefDQDvEwiDNbY8TE4ePGJHU3PbY82GgHWJhlpXFa1YUr/F8DOiIWJjl1Jnzp89Wej4GdEQszNLc9pjXIFBDLAA4QiwAOEIsADhCLAA4QiwAOEIsADhCLAA4QiwAOPI/siuj+0h84ZUAAAAASUVORK5CYII=" alt="" />

b:信号量:同一时间允许多个线程执行同一个动作。而不是上面的只允许单个线程同一时间执行同一个动作。

 import threading
import time
x=
q=threading.Semaphore()# 信号量,同一时间允许多少个线程执行相应的动作。
def f1(l,i): global x
l.acquire()#上锁。
x -=
time.sleep()
l.release()#开锁。 print(x,'NO %s thread'%i) for i in range():
t=threading.Thread(target=f1,args=(q,i))
t.start()
NO thread
NO thread
NO thread
NO thread
NO thread
NO thread
NO thread
NO thread
NO thread
NO thread

c:EVENT(事件):该事件是针对全部线程的动作,不是上面的单个或者多个。类似于红绿灯。红灯都不放行、绿灯都放行。

python线程的事件用于主线程控制其他线程执行,事件主要提供了三个方法:set wait clear。

事件处理机制:实际上python内部维护了一个全局的"flag",如果flag值为Flase(红灯)(默认是Flase),当执行到even.wait()时候,线程会阻塞。反之如果为True(绿灯)时候,event.wait()方法不会阻塞。

event.wait():检查全局flag值。如果是False,阻塞全部线程。反之放行。

event.clear()主动设置成全局变量为False.默认 值是False

event.set()主动设置全局变量为True。

 import threading
import time
x=
e=threading.Event()# 事件,同一时间阻塞所有线程或者同一时间放行所有线程。
def f1(l,i): global x
l.wait()#检查全局flag值。
x -= print(x,'NO %s thread'%i) for i in range():
t=threading.Thread(target=f1,args=(e,i))
t.start()
e.clear()#设置全局标志:flag=Flase 默认值是False。
if __name__=='__main__':
inp=input(">")
if inp=='':
e.set()##将全局标志:flag设置为True

d:Contidition 当满足一定条件时候,放行几个线程。

import threading
con=threading.Condition()#初始化一个Condition实例。 def func(c,i):
print(i)
c.acquire()
c.wait()
print(i+100)
c.release() for i in range(10):
t=threading.Thread(target=func,args=(con,i))
t.start() if __name__=="__main__":
while True:
inp=input('>>')
if inp=='q':
break
con.acquire()##固定语法,如果执行notify必须有acquire和release。
con.notify(int(inp))##表示满足inp不等于q的条件,放行几个线程。
con.release()
0
1
2
3
4
5
6
7
8
9
>>1
>>100
2
>>101

上面:

con.acquire()

con.notify()

con.release()

为固定用法,表示用户输入为数字的时候,通过notify方法通知程序放行几个线程。

也可以根据函数的返回的布尔值来判断是否放行线程如下,每次只放行一个线程:

 1 import threading
2 con=threading.Condition()#初始化一个Condition实例。
3
4 def m():
5 inp=input('>')
6 if inp=='1':
7 return True
8 else:
9 return False
10 def func(c,i):
11 print(i)
12 c.acquire()
13 c.wait_for(m)##wait_for()1:可被调用的方法而且需要返回值是布尔型。如果返回为真放行一个线程。反之不放行。
14 print(i+100)
15 c.release()
16
17
18
19 for i in range(10):
20 t=threading.Thread(target=func,args=(con,i))
21 t.start()

e:计数器,表示超时之后开始执行。

1 import threading
2
3 def func():
4 print(100)
5
6
7 t=threading.Timer(2,func)##2表示多久之后执行,func为可执行函数。
8 t.start()

e:线程池:

1:线程的复用,而不是重新创建一个线程。如果任务过多,重复的创建新的线程,上下文的开销(维护线程的开销)较多,资源浪费。

2:当线程池里的线程取完,下一次任务需要等待线程执行完,在执行。

如下是简单版本的多线程:

 import threading
import queue
import time class Thread_Poll:
q=queue.Queue()##定义队列。
def __init__(self,maxsize):
self.maxsize=maxsize#定义线程池队列的大小。 def put_thread(self):#往线程池里放线程类。
for i in range(self.maxsize):
Thread_Poll.q.put(threading.Thread) def get_thread(self):#返回一个线程类。
return Thread_Poll.q.get() def task(i):#执行的任务。
print(i)
time.sleep()
Thread_Poll.q.put(threading.Thread)#完成任务,需要补充线程池的线程。 if __name__=="__main__":
obj=Thread_Poll()
obj.put_thread()
for i in range():#执行任务。
t=obj.get_thread()(target=task,args=(i,))
t.start()

更新的第二版:

 #!/usr/bin/env python
# -*- coding:utf- -*-
# Author:Alex Li
import queue
import threading
import contextlib
import time StopEvent = object()#赋值。当任务等于他的时候,表示任务执行完毕。 class ThreadPool(object): def __init__(self, max_num, max_task_num = None):
if max_task_num:#任务数。
self.q = queue.Queue(max_task_num)#创建队列,队列的长度为任务数。
else:
self.q = queue.Queue()#如果没有传入,创建一个没有限制的队列。
self.max_num = max_num#线程的最大数。
self.cancel = False#取消线程执行
self.terminal = False#取消线程执行。
self.generate_list = []#保存正在执行任务线程对象的列表。
self.free_list = []#保存空余线程的列表。 def run(self, func, args, callback=None):
"""
线程池执行一个任务
:param func: 任务函数
:param args: 任务函数所需参数
:param callback: 任务执行失败或成功后执行的回调函数,回调函数有两个参数1、任务函数执行状态;、任务函数返回值(默认为None,即:不执行回调函数)
:return: 如果线程池已经终止,则返回True否则None
"""
if self.cancel:#如果cancel=True表示任务执行完。
return
if len(self.free_list) == and len(self.generate_list) < self.max_num:#当没有空闲线程和正在运行的线程数量小于总线程大小。
self.generate_thread()#执行创建线程的方法。
w = (func, args, callback,)#创建一个元组。func任务函数、args表示任务函数参数。callback任务执行完回调函数(任务执行状态successful还是fail以及任务函数的返回值)。
self.q.put(w)#往队列里添加任务。 def generate_thread(self):
"""
创建一个线程,并执行相应的call方法。
"""
t = threading.Thread(target=self.call)
t.start() def call(self):
"""
循环去获取任务函数并执行任务函数
"""
current_thread = threading.currentThread#获取当前的线程。
self.generate_list.append(current_thread)#把当前的线程放在列表中。 event = self.q.get()#获取任务。
while event != StopEvent:#任务不为空即:任务不等StopEvent。 func, arguments, callback = event#赋值。
try:
result = func(*arguments)#执行任务函数。
success = True#执行完,赋值表示执行成功。
except Exception as e:#报错,表示任务执行失败。
success = False
result = None if callback is not None:#任务回调函数不为空。
try:
callback(success, result)#执行回调函数,参数为任务状态以及任务结果。
except Exception as e:#执行回调函数报错的情况处理。
pass with self.worker_state(self.free_list, current_thread):
print(self.terminal)
if self.terminal:
event = StopEvent
else:
event = self.q.get()
else: self.generate_list.remove(current_thread) def close(self):
"""
执行完所有的任务后,所有线程停止
"""
self.cancel = True
full_size = len(self.generate_list)
while full_size:
self.q.put(StopEvent)
full_size -= def terminate(self):
"""
无论是否还有任务,终止线程
"""
self.terminal = True while self.generate_list:
self.q.put(StopEvent) self.q.empty() @contextlib.contextmanager
def worker_state(self, state_list, worker_thread):
"""
用于记录线程中正在等待的线程数
"""
state_list.append(worker_thread)
try:
yield
finally:
state_list.remove(worker_thread) pool = ThreadPool() def callback(status, result):
# status, execute action status
# result, execute action return value
pass def action(i):
print(i) for i in range():
ret = pool.run(action, (i,), callback) # time.sleep()
# print(len(pool.generate_list), len(pool.free_list))
# print(len(pool.generate_list), len(pool.free_list))

更新第三版:

 #!/usr/bin/env python
# -*- coding:utf- -*-
# Author:evil_liu
import queue
import threading
import contextlib
import time StopEvent = object()#赋值。当任务等于他的时候,表示任务执行完毕。
RES_LIST=[]
class ThreadPool():
count=
lock=threading.RLock()#线程锁
def __init__(self, max_num, max_task_num):
self.max_task_num=max_task_num# 任务计数。
if max_task_num:#任务数。
self.q = queue.Queue(max_task_num)#创建队列,队列的长度为任务数。
else:
self.q = queue.Queue()#如果没有传入,创建一个没有限制的队列。
self.req=queue.Queue(max_task_num)##结果队列。
self.max_num = max_num#线程的最大数。
self.cancel = False#取消线程执行
self.terminal = False#取消线程执行。
self.generate_list = []#保存正在执行任务线程对象的列表。
self.free_list = []#保存空余线程的列表。 def run(self, func, args, callback=None):
"""
线程池执行一个任务
:param func: 任务函数
:param args: 任务函数所需参数
:param callback: 任务执行失败或成功后执行的回调函数,回调函数有两个参数1、任务函数执行状态;、任务函数返回值(默认为None,即:不执行回调函数)
:return: 如果线程池已经终止,则返回True否则None
"""
if self.cancel:#如果cancel=True表示任务执行完。
return
if len(self.generate_list) < self.max_num:#当没有空闲线程和正在运行的线程数量小于总线程大小。
self.generate_thread()#执行创建线程的方法。
w = (func, args, callback,)#创建一个元组。func任务函数、args表示任务函数参数。callback任务执行完回调函数(任务执行状态successful还是fail以及任务函数的返回值)。
self.q.put(w)#往队列里添加任务。 def generate_thread(self):
"""
创建一个线程,并执行相应的call方法。
"""
t = threading.Thread(target=self.call)
t.start() def call(self):
"""
循环去获取任务函数并执行任务函数
"""
current_thread = threading.currentThread#获取当前的线程。
self.generate_list.append(current_thread)#把当前的线程放在列表中。 event = self.q.get()#获取任务。
while event != StopEvent:#任务不为空即:任务不等StopEvent。 func, arguments, callback = event#赋值。
# if ThreadPool.count <= self.max_task_num:
try:
result = func(*arguments)#执行任务函数。
success = True#执行完,赋值表示执行成功。
except Exception as e:#报错,表示任务执行失败。
success = False
result = None
if callback is not None:#任务回调函数不为空。
try:
callback(success, result)#执行回调函数,参数为任务状态以及任务结果。
except Exception as e:#执行回调函数报错的情况处理。
pass try:
event = self.q.get(timeout=)#获取数据超时。超时之后表示任务执行完成。
except queue.Empty as e:
self.generate_list.remove(threading.currentThread)##释放线程
break
def close(self):
"""
执行完所有的任务后,
"""
self.cancel = True
full_size = self.max_num
while full_size:
self.q.put(StopEvent)
full_size -= pool = ThreadPool(,)
# lock_1=threading.RLock()
def callback(status, result):
pass def action(i):
print("Now mssion is %s"%i)
time.sleep()
return True for i in range():
ret = pool.run(action, (i,), callback)
time.sleep()
print(len(pool.generate_list))

终极版:

 #!/bin/env python
#author:evil_liu
#date:--
#description: thread pool import threading
import time
import queue class Thread_Poll:
'''
功能:该类主要实现多线程,以及线程复用。
'''
def __init__(self,task_num,max_size):
'''
功能:该函数是初始化线程池对象。
:param task_num: 任务数量。
:param max_size: 线程数量。
:return:无。
'''
self.task_num=task_num
self.max_size=max_size
self.q=queue.Queue(task_num)#设置任务队列的。
self.thread_list=[]
self.res_q=queue.Queue()#设置结果队列。 def run(self,func,i,call_back=None):
'''
功能:该函数是线程池运行主函数。
:param func: 传入任务主函数。
:param *args: 任务函数参数,需要是元组形式。
:param call_back: 回调函数。
:return: 无。
'''
if len(self.thread_list)<self.max_size:#如果目前线程数小于我们定义的线程的个数,进行创建。
self.creat_thread()
misson=(func,i,call_back)#往任务队列放任务。
self.q.put(misson) def creat_thread(self):
'''
功能:该函数主要是创建线程,并调用call方法。
:return: 无。
'''
t=threading.Thread(target=self.call)
t.start() def call(self):
'''
功能:该函数是线程循环执行任务函数。
:return: 无。
'''
cur_thread=threading.currentThread
self.thread_list.append(cur_thread)
event=self.q.get()
while True:
func,args,cal_ba=event#获取任务函数。
try:
res=func(*args)#执行任务函数。注意参数形式是元组形式。
flag="OK"
except Exception as e:
print(e)
res=False
flag="fail"
# print(flag)
self.res(res,flag)#调用回调函数,将执行结果返回到队列中。
try:
event=self.q.get(timeout=)#如果任务队列为空,获取任务超时2s超过2s线程停止执行任务,并退出。
except Exception:
self.thread_list.remove(cur_thread)
break
def res(self,res,status):
'''
功能:该方法主要是将执行结果方法队列中。
:param res: 任务函数的执行结果。
:param status: 执行任务函数的结果,成功还是失败。
:return: 无。
'''
da_res=(res,status)
self.res_q.put(da_res) def task(x,y):
'''
功能:该函数主要需要执行函数。
:param x: 参数。
:return: 返回值1,表示执行成功。
'''
print(x)
return x+y
def wri_fil(x):
'''
功能:该函数主要讲结果队列中的结果写入文件中。
:param x: 任务长度。
:return: 无。
'''
while True:#将执行结果,从队列中获取结果并将结果写入文件中。
time.sleep()
if pool.res_q.qsize()==x:#当队列当前的长度等于任务执行次数,表示任务执行完成。
with open('1.txt','w') as f1:
for i in range(pool.res_q.qsize()):
try:
data=pool.res_q.get(timeout=)
f1.write('mission result:%s,status:%s\n'%data)
except Exception:
break
break
else:
continue
if __name__ == '__main__':
pool=Thread_Poll(,)#初始化线程池对象。
for i in range():#循环任务。
pool.run(task,(,))
wri_fil()

以上版本在window pycharm运行有时候出现程序hang住无法结束。但是linux测试没有这个问题。

f:进程:

执行脚本的时候,别在window下创建多进程,因为python是调用os.fork创建,而window不支持,想执行需要用:if __name__=="__main__".

a:多进程的创建:

 import multiprocessing

 def test(x):
print(x) if __name__ == '__main__':
p=multiprocessing.Process(target=test,args=(,))
p.start()
 import multiprocessing
import time
def test(x):
time.sleep()
print(x) if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(i,))
p.start()
p.join()#这个参数的意思是:进程在这等待6秒,6秒之后就往下执行代码,后面的代码执行完,不终止。等待子进程执行完。不加该参数默认会等待进程执行完。
print('ok')

daemon=True表示进程不等待子进程执行完。结束程序。

 import multiprocessing
import time
def test(x):
time.sleep()
print(x) if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(i,))
p.daemon = True##注意位置,在start之前。
p.start()
print('ok')

b:进程之间的数据共享:

进程之间数据不共享,单独维护一个块系统资源(内存空间.....)来维护自己的数据资源。

 import multiprocessing
LI=[]
def test(x,li):
li.append(x)
print(li) if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(i,LI))
p.start()
[]
[]

数据共享可以用如下:Queue方法可以构造特殊的数据,该方法包含put、get等。

 import multiprocessing
from multiprocessing.queues import Queue
li=Queue(,ctx=multiprocessing)
def test(y,x):
y.put(x)
print(y.qsize()) if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(li,i))
p.start()

c:Array() 数组的方法。来构建进程共享数据:不常用。

1)数组需要指定类型。

 'c': ctypes.c_char,  'u': ctypes.c_wchar,
'b': ctypes.c_byte, 'B': ctypes.c_ubyte,
'h': ctypes.c_short, 'H': ctypes.c_ushort,
'i': ctypes.c_int, 'I': ctypes.c_uint,
'l': ctypes.c_long, 'L': ctypes.c_ulong,
'f': ctypes.c_float, 'd': ctypes.c_double 类型对应表

2)数组需要指定长度。

 import  multiprocessing

 def test(x,y):
x[y]=y+
for i in x:
print(i)
print("------------------") li=multiprocessing.Array('i',)
if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(li,i))
p.start()

在大多数语言中:数组类型的数据,在内存中是连续的一块内存,需要指定数据的大小、类型(类型的不同的占有的位置大小也不一样,需要提前指定。)python 的列表,具有可扩展、伸缩。在内存中的数据块地址是不连续的。是因为在内存中,内存数据块是通过链表的形式进行查看。

就是说一个数据记录上个数据的内存地址和下个数据的内存地址。这样的方式进行查找。

常用的方式:用multiprocessing模块的Manger()方法,使用字典形式的进行数据更改,没有数据类型的限制。

 import  multiprocessing

 def test(x,y):
x[y]=y+
for i in x.items():
print(i)
print("------------------")
obj=multiprocessing.Manager()
t=obj.dict()
# li=multiprocessing.Array('i',)
if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(t,i))
p.start()
p.join()##注意:需要加join等待子进程执行完。因为修改的是主进程的数据,主进程需要和子进程进行socket链接。如果不等子进程执行完,就执行子进程。会导致主进城和子进程通讯出现问题。
(, )
------------------
(, )
(, )
------------------
(, )
(, )
(, )
------------------
(, )
(, )
(, )
(, )
------------------

c:进程锁。

当进程的数据进行共享的时候,多个进程操作共享数据之后,获得数据的结果会出现混乱。

 import  multiprocessing
import time
LOCK=multiprocessing.Lock()
def test(x,l):
x[]-=
time.sleep()
print(x[])
obj=multiprocessing.Manager()
t=obj.dict()
if __name__ == '__main__':
t[]=
for i in range():
p=multiprocessing.Process(target=test,args=(t,LOCK))
p.start()
p.join()#####################注意join位置。
 import  multiprocessing
import time
LOCK=multiprocessing.Lock()
def test(x,l):
x[]-=
time.sleep()
print(x[])
obj=multiprocessing.Manager()
t=obj.dict()
if __name__ == '__main__':
t[]=
for i in range():
p=multiprocessing.Process(target=test,args=(t,LOCK))
p.start()
p.join()####################这个位置就是逐个执行。

加锁:同样进程也有进程普通锁、递归锁、event、condition等。和线程使用的方式类同!

 import  multiprocessing
import time
LOCK=multiprocessing.Lock()
def test(x,l):
x[]-=
time.sleep()
print(x[])
obj=multiprocessing.Manager()
t=obj.dict()
if __name__ == '__main__':
t[]=
for i in range():
p=multiprocessing.Process(target=test,args=(t,LOCK))
p.start()
p.join()
 import  multiprocessing
import time
LOCK=multiprocessing.Semaphore()##信号量。 def test(x,l):
LOCK.acquire()
x[]+=
time.sleep()
l.release()
print(x[])
obj=multiprocessing.Manager()
t=obj.dict()
t[]=
if __name__ == '__main__':
for i in range():
p=multiprocessing.Process(target=test,args=(t,LOCK))
p.start()
p.join()

event:

 import  multiprocessing
e=multiprocessing.Event() def test(x,l):
x[]+=
l.wait()
print(x[])
obj=multiprocessing.Manager()
t=obj.dict()
t[]=
for i in range():
p=multiprocessing.Process(target=test,args=(t,e))
p.start()
if __name__ == '__main__':
inp=input(">")
if inp=='':
e.set()
>

conditon()

 import  multiprocessing
e=multiprocessing.Condition() def test(x,l):
l.acquire()
l.wait()
x[]+=
print(x[])
l.release()
obj=multiprocessing.Manager()
t=obj.dict()
t[]=
for i in range():
p=multiprocessing.Process(target=test,args=(t,e))
p.start()
if __name__ == '__main__':
inp=input(">")
while True:
if inp!='q':
e.acquire()
e.notify(int(inp))
e.release()

d:进程池。

进程multiprocessing给我们提供了相应的方法。分别为:appy方法、app_async方法。

appy方法:并不是并发执行任务,而是当前进程执行完,才执行下个,串行执行。

 import multiprocessing
import time def task(args):
time.sleep()
print(args) pool=multiprocessing.Pool()##初始化5个进程。
if __name__ == '__main__':
for i in range():
pool.apply(func=task,args=(i,))#从进程调用一个进程执行任务。
print("_____end_____") _____end_____

app_async()异步执行(从队列获取任务,执行任务。),这个比较常用。可以看做是并发执行任务。

 import multiprocessing
import time def task(args):
time.sleep()
print(args) pool=multiprocessing.Pool()##初始化5个进程。
if __name__ == '__main__':
for i in range():
pool.apply_async(func=task,args=(i,))#从进程调用一个进程执行任务。
pool.close()##执行close或者terminal方法,要不然会报断言错误。terminnal方法表示任务立即终止。
pool.join()#主进程等待子进程执行完任务。
print("_____end_____")

协程:

原理:多线程、多进程是系统执行的。而协程是程序员”操纵“。将一个线程分解成多个“微线程”,执行不同的任务。比如说:多次URL请求。每次URL请求耗时3S。如果用多线程执行的话,会出现资源浪费(维护、等待3s),可以用协程,我们可以让线程循环执行url请求,而不是在等待执行结果。也就说。可以在等待的同时执行其他的任务。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATQAAAEeCAIAAACL1H6YAAAOUUlEQVR4nO3d22HqOhCFYdXlglSPq3EzFEMefEG+xmPL4xnp/15ODjuAtOQVAQkmfAGYFN4eAIBtlBMwinICRlFOwCjKCRhFOQGjKCdgFOVEET5tbD/zC5rYvTWaPCgnjnSxadsYVmL37X4Xb3xP01eli83Ymd22dHFxc+kN/D/AMNxqF5v282mb9WBDWN5xP5ZP25y8l3dQTuwa6vQr2KpfywuSLq4u2Cznp21WzRH5lfP77WJyU4c75/SP6dXNoZzY1m8rezvnsLEtGjDv5m8vbGKcb2j9lcada1VpgWW7NrfOjY35n63VBMqJXUN5Tu+cGyVLLppqtPi2LobYbXVneJSabIz915+2CTHGqXT9A9RlxdY7Z9Lj2xu2Crvl3PsZ9/a4qtENh//W887+4vk2+mmb3nwvDSGEGGNommb9PHTrcWXaqt1yTpf+rv9pm9huP+WcnsDObqK/sItG903j5Tx5IZ7QxdiOzzljlxYqaU/yZRfDcIXhe4fdrGk/367rfl1PyjlU90I5Vxf+rrfYmNc7aD+wschGi/n9Uk4cmF7TXD3sXJUz+dbvvH7DV5+2adqubUJS9C7GbrM7N8t58ITy0zbDw+XhwbDll2vtHuuU83Wf30a4v3OG/vWesTbp7zVm/w3zJ5/jPxyXM7ne78Hs1Z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R1fWoufD5ncXwkVdK6PlfOEPh8zqK4SaqMpX3oITqfz1kkN0mVsbQPzoLP5yyOm6Qe2nM0PTsFPp+zOJ6S8t7PZwfP53MWx1lSfhf40Z8sfD5nkZwl5XTzdDrsvEhAyl9SHg90dwN+AiFI+UvKXTkzDtjLlDf5WjULXCblqJ95m+liynu8j1+f16S89DN7M43P94D38evzmpSLg5VtM1XAFJQ5Tsp4P59ops2ZnlTAFJT5TsrsUZtrYKGgT7YsYxaa3CdlsJ8Zm1mwXGkXrISMTC15xsHolkVblrTLVkhGRlY97zB0y6Ltfj7FKyejd9f+oXsv6WguZiJqikrqrX4+er/FHNPFTERNaUkpP3xSuLtiNs8yZqGpzKR0+qn2U6CMw7qMWWgqNqn1npbxsFDen6d7fPpeHkU5pQpPKm9FHy188UhMqoqkNkt18kC5c12kyE2qoqQOaib19lRcIj2pGpOik68gRqnak6KQaohUiqSghHJKkRSUUE4pkoISyilFUlBCOaVICkoopxRJQQnllCIpKKGcUiQFJZRTiqSghHJKkRSUUE4pkoISyilFUlBCOaVICkoopxRJQQnllCIpKKGcUiQFJZRTiqSghHJKkRSUUE4pkoISyilFUlBCOaVICkoopxRJQQnllCIpKKGcUiQFJf+Wk/YuEATy2+zYcfdC4vkB+kAQyGyvZgfdC3NaI7WOIJCZtJw0cw9ZIL/Nsh03lmauEQcesa7cQV1p5iYSwVMWxdvrKs3cQyh4UNiyvvztYRpFLnjWZj9p5hlEg8fRzGtIB4+jmdcQEDTQzAvICEpophQxQQnNlCIpwCjKCRhFOQGjKCdgFOUEjKKcgFGUEzCKcgJGUU7AKMoJGEU5AaMoJ2AU5QSMopyAUZQTMIpyAkZRTsAoygkYRTkBoygnYBTlBIyinIBRlBMwinICRv0BtSKT1bBk008AAAAASUVORK5CYII=" alt="" />

通过gevnet和greenlet方法执行。genvent是对greenlet的封装,底层还是调用greenlet。

安装:pip install gevent(安装这个自动安装greenlet)

 from greenlet import greenlet

 def test1():
print()
gr2.switch()
print()
gr2.switch() def test2():
print()
gr1.switch()
print() gr1 = greenlet(test1)
gr2 = greenlet(test2)
gr1.switch()

如上代码:当执行到gr1.switch()的时候,会执行test1函数,执行到test1函数到gr2.switch()的时候执行test2, 遵循这个规则依次执行下去。也就是说通过greenlet来控制线程的执行流。

 import gevent

 def foo():
print('Running in foo')
gevent.sleep()#执行切换。
print('Explicit context switch to foo again') def bar():
print('Explicit context to bar')
gevent.sleep()#执行切换。
print('Implicit context switch back to bar') gevent.joinall([
gevent.spawn(foo),
gevent.spawn(bar),
])##创建协程。
Running in foo
Explicit context to bar
Explicit context switch to foo again
Implicit context switch back to bar

IO操作:执行http请求。

 from gevent import monkey; monkey.patch_all()
import gevent
import requests def f(url):
print('GET: %s' % url)
resp = requests.get(url)
data = resp.text
print('%d bytes received from %s.' % (len(data), url)) gevent.joinall([
gevent.spawn(f, 'https://www.python.org/'),
gevent.spawn(f, 'https://www.yahoo.com/'),
gevent.spawn(f, 'https://github.com/'),
])#创建协程、循环执行这个url
GET: https://www.python.org/
GET: https://www.yahoo.com/
GET: https://github.com/
bytes received from https://www.python.org/.
bytes received from https://github.com/.
bytes received from https://www.yahoo.com/.

monkey.patch_all()
底层封装socket,具有可以让线程可以一边执行url请求,一边可以收到url请求的结果。

应用场景:在python爬虫框架:scrapy就是用协程(gevent)来实现的,比较高效。

url存活检测(上线之后检测url的存活情况)。

一旦涉及到IO操作,比如http请求,gevent执行效率很高。

缓存:

本质:python通过socket连接服务端(缓存端)通过端口,建立连接 ,在服务端执行相应的命令。

安装memcache:

1:

 wget http://memcached.org/latest
yum install -y libevent-devel.x86_64#64位操作系统。
./configure
make && make install

虚拟机用的是网易的源。yum配置文件:

 [base_server]
name=base_server
baseurl=http://mirrors.163.com/centos/6.8/os/x86_64/
enabled=
gpgcheck=

启动:

memcached -d -m     -u root  -p   -c  -P /tmp/memcached.pid

参数说明:

 参数说明:
-d 是启动一个守护进程
-m 是分配给Memcache使用的内存数量,单位是MB
-u 是运行Memcache的用户
-l 是监听的服务器IP地址
-p 是设置Memcache监听的端口,最好是1024以上的端口
-c 选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定
-P 是设置保存Memcache的pid文件

memcache处理的数据类型:

a)key value形式:

 #!/usr/bin/env python
#-*-coding:utf--*-
# author:liumeide
import memcache mc = memcache.Client(['192.168.1.104:11211'], debug=True)
mc.set("OK", "evil")#设置键值对。
ret = mc.get('OK')#获取键值对。
print(ret)
evil

debug=True:表示运行过程中如果出现错误,显示错误信息。

b)支持集群操作:

python-memcached模块原生支持集群操作,其原理是在内存维护一个主机列表,且集群中主机的权重值和主机在列表中重复出现的次数成正比

      主机      权重
10.10.1.1
10.10.1.2
10.10.1.3 那么在内存中主机列表为:
host_list = ["10.10.1.1", "10.10.1.2", "10.10.1.2", "10.10.1.3", ]

如果用户根据如果要在内存中创建一个键值对(如:k1 = "v1"),那么要执行一下步骤:

  • 根据算法将 k1 转换成一个数字
  • 将数字和主机列表长度求余数,得到一个值 N( 0 <= N < 列表长度 )
  • 在主机列表中根据 第2步得到的值为索引获取主机,例如:host_list[N]
  • 连接 将第3步中获取的主机,将 k1 = "v1" 放置在该服务器的内存中

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASMAAAEXCAIAAABpqbXBAAARkklEQVR4nO2dW6KjKhAAsy4X5HpcjZtxMd4PH9DQLWhID55b9TMTj6ICBUhC+1kB4Pd8/vUFAPwvwDQADzANwANMA/AA0wA8wDQADzANwANMA/AA0wA8wDQADzDNYpmGz2eYFrl1Hj872Z9+dOCdHaBfME3BsmIezy3LNHw+4/zrA+t3gM7BNJt5lNVafl6mITem8YH3d4BewTSbpFrPo+yM0s/tD3ywA/QKptnkwqQ9VbVpzw58sAP0CqbZFISxR4GtDnywA/QKptmUB4H29EWTAx/sAL2CaTZJtV6m4dnExuMDH+wAvYJpNlm1jjqnyJ583r7VgRUpw1vANIXw5dXOWduXadC3bZ8aH1iVMrwDTAPwANMAPMA0AA8wDcADTAPwANMAPMA0AA8wDcADTAPwANM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joXpkNTiQXlfR18Na2PO3wtcZZT2BYvmfVKQR5JKMxsHc/2IiRGRTF9Z37VpTanttgB+wf/HNIB/CaYBeIBpAB5gGoAHmAbgAaYBeIBpAB5gGoAHmAbgAaYBeIBpAB5gGoAHmAbgAaYBeIBpAB5gGoAHmAbgwX+6kOpf2V7SHQAAAABJRU5ErkJggg==" alt="" />

代码实现如下:

 mc = memcache.Client([('10.10.10.1:12000', ), ('10.10.1.2:12000', ), ('10.10.1.3:12000', )], debug=True)

 mc.set('key1', 'value1')

c) add 添加一条键值对,如果有报错:MemCached: while expecting 'STORED', got unexpected response 'NOT_STORED'

 mc = memcache.Client(['192.168.1.104:11211'], debug=True)
mc.add("ok", "tom")#添加键值对。
ret = mc.get('ok')#获取键值对。
print(ret)
tom

d)replace修改某个键值对。如果不存在报异常:MemCached: while expecting 'STORED', got unexpected response 'NOT_STORED'

 import memcache

 mc = memcache.Client(['192.168.1.104:11211'], debug=True)
mc.replace("ok", "come")#添加键值对。
ret = mc.get('ok')#获取键值对。
print(ret)
come

e)set修改键值对,如果不存在话创建,存在的话进行修改,这个一对一。set_multi  是对多个键值对进行修改。注意多个时候,里面放的是字典key:value。

 import memcache

 mc = memcache.Client(['192.168.1.104:11211'], debug=True)
mc.set("", "come")#如果存在,修改,不存在创建。
mc.set_multi({"ok": "bye","cc":})#如果存在,修改,不存在创建。
ret = mc.get('ok')#获取键值对。
ret1 = mc.get('')#获取键值对。
print(ret,ret1)
bye come

f) delet delet_multi删除键值对,删除多个键值对。需要注意删除里面是key值而且是列表。

 import memcache

 mc = memcache.Client(['192.168.1.104:11211'], debug=True)
mc.delete("")#如果存在,修改,不存在创建。
mc.delete_multi(["ok","cc"])#如果存在,修改,不存在创建

g) get 和get_multi获取键值对、多个键值对。

import memcache

mc = memcache.Client(['192.168.1.104:11211'], debug=True)
mc.set("", "come")#如果存在,修改,不存在创建。
mc.set_multi({"ok": "bye","cc":})#如果存在,修改,不存在创建。。
ret = mc.get('ok')#获取键值对。
ret1 = mc.get_multi(['','ok'])#获取多个键值对。
print(ret,ret1)
bye {'': 'come', 'ok': 'bye'}

h)append 和 prepend,append在修改指定的key值,在该值的后面追加内容,prepend则相反。

 mc.append("",)
ret=mc.get("")
print(ret)
come22
 mc.prepend("",)
ret=mc.get("")
print(ret)
22come22

i)decr和incr  将memcache中的一个值减少(默认是1)或者增加

 ret=mc.get("cc")
mc.decr("cc")
ret1=mc.get("cc")
print(ret,ret1)
 ret=mc.get("cc")
mc.incr("cc",)
ret1=mc.get("cc")
print(ret,ret1)

j)cas和gets

比如说:我们在淘宝进行抢购商品的时候,没抢购一次,相应的存货应该自减,但是如果在相同时间内程序获取相同的存货数据,修改提交。在memcache中,会出现数据的不一致。

这样导致数据的混乱,cas和gets就是解决这个问题。类似线程的互斥锁的作用,memcache内部:每当程序来获取数据的时候,返回当前一个数字和对应的键值,当用户提交修改的时候。

memcache会把当前的数字和程序提交的数字进行比对,如果相等,说明这段时间内没有程序进行修改,如果不相等,提交失败。修改不了。

 v=mc.gets("cc")
time.sleep()
#在gets和cas之间如果有提交数据,在下面的cas不成功。我测试没出现异常?也正常修改。。。。
mc.cas("cc",)

安装redis

wget http://download.redis.io/releases/redis-3.0.6.tar.gz
tar xvzf redis-3.0..tar.gz
cd redis-3.0.
make PREFIX=/export/server/redis install

启动:

 nohup /export/server/redis/bin/redis-server &

安装API:

 pip.exe install redis

redis针对数据类型:

1:字符串string.

2:hash 操作。

3:列表操作。

4:集合操作。

5:排序操作,比如说:([(11,1),(12,2)])根据后面第二值进行操作。

6:管道

7:发布订阅

a)操作:

添加值:

 import redis

 rc=redis.Redis(host="192.168.1.104",port=)
rc.set("test","ok")
v=rc.get("test")
print(str(v,encoding="utf-8"))
ok

注意:返回的结果是字节!!!!

b)连接方式:连接池

redis-py使用connection pool来管理对一个redis server的所有连接,避免每次建立、释放连接的开销。默认,每个Redis实例都会维护一个自己的连接池。可以直接建立一个连接池,然后作为参数Redis,这样就可以实现多个Redis实例共享一个连接池

 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
r.set('ok', '')
print(str(r.get('ok'),encoding="utf-8"))

c)操作:

字符串:redis中。字符串是按照一个name对应一个value来存储。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXIAAADnCAIAAACMmkoaAAAYO0lEQVR4nO2de3CTZb7Hv8lMZmPFQGYnQx0rRCZ/kBYqTWfLFBPwoDvcdKDuWQozLLpsRaHlDFhh1dWpu16O50BZd6bc1oPo6DnurrMHb+Um5aJdLi2lgvXQqlCqNl5a1zZQTLmeP9J20vTN+ybP86bkTb7fyV/Mk+98J7+XD7/nfZ+XH65p6dy5c5prrl27FgwGL168GMtKv9+vryETyhsyobwhEw4IyRNF2JAJ5Q2ZUN6QCQdErCiICeUNmVDe0LgJiRUFMaG8IRPKGxo3IbGiICaUN2RCeUPjJiRWFMSE8oZMKG9o3ITEioKYUN6QCeUNjZuQWFEQE8obMqG8oXETIqilQCCguSYYDPb09Fy4cCGWlX6/X19DJpQ3ZEJ5QyYcEC5qKRAIaK65ePHihQsXfvzxx1hW+v1+fQ2ZUN6QCeUNmXBA3AQpiAnlDZlQ3tC4CYkVBTGhvCETyhsaNyGxoiAmlDdkQnlD4yYkVhTEhPKGTChvaNyExIqCmFDekAnlDY2bkFhREBPKGzKhvKFxExIrCmJCeUMmlDc0bkJiRUFMKG/IhPKGxk1IrCiICeUNmVDe0LgJiRUFMaG8IRPKGxo3IbGiICaUN2RCeUPjJiRWFMSE8oZMKG9o3IQ4p6VAIKC5JrQsxpV+v19fQyaUN2RCeUMmHBC7FQUxobwhE8obGjchsaIgJpQ3ZEJ5Q+MmJFYUxITyhkwob2jchMSKgphQ3pAJ5Q2Nm5BYURATyhsyobyhcRMSKwpiQnlDJpQ3NG5CYkVBTChvyITyhsZNSKwoiAnlDZlQ3tC4CYkVBTGhvCETyhsaNyGxoiAmlDdkQnlD4yYkVhTEhPKGTChvaNyExIqCmFDekAnlDY2bkMN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/tnrp/pftL9k4d/ghLwE/tn7Jqxc/80d8/JPed7zutVlAQOS71/6/0oASqJFWmsvAs8hMUvLdYsShoOS2VCecNhS6jDJuhY6zGUAGVAJfBX4D1iJX6sfAe8BazGiNIR9a31ws1nhIIptAliQnnDYUuoA1auXr26cd9GlAAPptCmd/j3vQ9hROmItTvWXr16VbicEUrCC07YkAnlDY2ElZAOf3p4zp/mTHp60g3Lbrju20jDfcY/Ob54c/EHpz4IBoMy5YxQEl5wwoZMKG9oPKykw48lbMiE8oZMKG9IrCTjjyVsyITyhkwob0isJOOPJWzIhPKGTChvSKwk448lbMiE8oZMKG9IrCTjjyVsyITyhkwob0isJOOPJWzIhPKGTChvSKwk448lbMiE8oZMKG9IrCTjjyVsyITyhkwob0isJOOPJWzIhPKGTChvOHxY8Wupu7tbc43f7+/s7Ozo6IhlZXt7u76GTChvyITyhkw4IHYrCmJCeUMmlDc0bkJiRUFMKG/IhPKGxk1IrCiICeUNmVDe0LgJiRUFMaG8IRPKGxo3IbGiICaUN2RCeUPjJiRWFMSE8oZMKG9o3ITEioKYUN6QCeUNjZuQWFEQE8obMqG8oXETEisKYkJ5QyaUNzRuQmJFQUwob8iE8obGTUisKIgJ5Q2ZUN7QuAmJFQUxobwhE8obGjehDsNSQ7q+YzT1NWRCeUMmlDc0bkIdhqWGlA4jIIUNmVDekAnlDY00LFWvxknYkAnlDZlQ3pAJB0SsKIgJ5Q2ZUN7QuAmJFQUxobwhE8obGjchsaIgJpQ3ZEJ5Q+MmJFYUxITyhkwob2jchP8P3yVCvry9G7kAAAAASUVORK5CYII=" alt="" />

set(name, value, ex=None, px=None, nx=False, xx=False)

 在Redis中设置值,默认,不存在则创建,存在则修改
参数:
ex,过期时间(秒)
px,过期时间(毫秒)
nx,如果设置为True,则只有name不存在时,当前set操作才执行
xx,如果设置为True,则只有name存在时,岗前set操作才执行

设置过期时间:

 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
r.setex('ok', '',)
print(str(r.get('ok'),encoding="utf-8"))

mset(*args, **kwargs) 批量设置

 批量设置值
如:
mset(k1='v1', k2='v2')

mget({'k1': 'v1', 'k2': 'v2'})
 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
r.mset(a="",b="")
print(str(r.get("a"),encoding="utf-8"))

mget(keys, *args)批量获取值

 批量获取
如:
mget('ylr', 'xi')

r.mget(['ylr', 'x'])

append(key, value)

 # 在redis name对应的值后面追加内容

 # 参数:
key, redis的name
value, 要追加的字符串

incrbyfloat(self, name, amount=1.0)

 # 自增 name对应的值,当name不存在时,则创建name=amount,否则,则自增。

 # 参数:
# name,Redis的name
# amount,自增数(浮点型)

decr(self, name, amount=1)

 # 自减 name对应的值,当name不存在时,则创建name=amount,否则,则自减。

 # 参数:
# name,Redis的name
# amount,自减数(整数)

Hash操作:

存储:如下图:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT8AAAEPCAIAAAC7vlRRAAAgAElEQVR4nO2dfXAUdZrHv9N3fdXXdzZOWV3MnSNpqbkqZoakZKilCjdBFl0RYjjO3cWXdV0POFATFg8WrFPXrLuL4onn6UWQchF2ARHWVWFFBUF5DRAS3sIqyLuY8JKgMLwY3u+PzkwmmUnS3b8ekpl8n5q/muaz3/K5Tz2/6Z7jQUNSnT179ty5c8nXk6u2ttbKbdaB0WjUXSATigOZUByYpoS4kFTnzp377rvvkq8nV21trZXbrAOj0ai7QCYUBzKhODBNCXE1qRoaGi5cuJB8Pblqa2ut3GYdePr0aXeBTCgOZEJxYJoS0l57QCYUBzKhOJD2OgEyoTiQCcWBtNcJkAnFgUwoDqS9ToBMKA5kQnEg7XUCZEJxIBOKA2mvEyATigOZUBxIe50AmVAcyITiQNrrBMiE4kAmFAfSXidAJhQHMqE4kPY6ATKhOJAJxYG01wmQCcWBTCgObLT3dFJFo9FoNJp8Pblqa2ut3GYdaP02JmzjTneBTCgOTFNCzl57QCYUBzKhOPA0T84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z/ulW0s1dYGdOmPfrvId+/9D75e9funzJ9S7TXntAJhQHMqE4kPY6ATKhOJAJxYG01wmQCcWBTCgOpL1OgEwoDmRCcSDtdQJkQnEgE4oDaa8TIBOKA5lQHEh7nQCZUBzIhOJA2usEyITiQCYUB9JeJ0AmFAcyoTiQ9joBMqE4kAnFgbTXCZAJxYFMKA5stLc2qerr6+vq6pKvJ1dNTY2V26wDT5065S6QCcWBTCgOTFNCzl57QCYUBzKhOJAnZydAJhQHMqE4kPY6ATKhOJAJxYG01wmQCcWBTCgOpL1OgEwoDmRCcSDtdQJkQnEgE4oDaa8TIBOKA5lQHEh7nQCZUBzIhOJA2usEyITiQCYUB9JeJ0AmFAcyoTiQ9joBMqE4kAnFgbTXCZAJxYFMKA5stLchqTrnFg9nQCYUBzKhODBNCf8f1Zy34askGjUAAAAASUVORK5CYII=" alt="" />

hset(name, key, value)

 # name对应的hash中设置一个键值对(不存在,则创建;否则,修改)

 # 参数:
# name,redis的name
# key,name对应的hash中的key
# value,name对应的hash中的value # 注:
# hsetnx(name, key, value),当name对应的hash中不存在当前key时则创建(相当于添加)

hmset(name, mapping)

 # 在name对应的hash中批量设置键值对

 # 参数:
# name,redis的name
# mapping,字典,如:{'k1':'v1', 'k2': 'v2'} # 如:
# r.hmset('xx', {'k1':'v1', 'k2': 'v2'})

hget(name,key)

 # 在name对应的hash中获取根据key获取value

hmget(name, keys, *args)

 # 在name对应的hash中获取多个key的值

 # 参数:
# name,reids对应的name
# keys,要获取key集合,如:['k1', 'k2', 'k3']
# *args,要获取的key,如:k1,k2,k3 # 如:
# r.mget('xx', ['k1', 'k2'])
# 或
# print r.hmget('xx', 'k1', 'k2')

List操作:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARkAAACTCAIAAAA1LvpKAAALMElEQVR4nO2cz0/T/h/H+ZfoDB8lG/gjHJCELBBJwAMe8EfYiRFjDMhIdlliRA4YlMrJH7iLMVFjLyYezEQTjGhNOCgJMNooC3GdG0ht9j28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hXjre9cl0zQnJyfFv8Wa5nwmXkWXBOF5DX78VYYbGxs7/Rsiu0s1bwHEw/HPnz9Xq1VFUZzPD6qeR+euLjlH7XDRmVKp5BpFl0L0GvyAIR1Y8zmejaqqmUzGz1CM+hm6Rl2GzlF0qVoN02vwA4Z0oPPvHrwoipLL5fwMxaifoWvUZWiP4u8e/k94XoMfMNx7IAz5gegSDClgyA9El2BIAUN+ILoEQwoY8gPRJRhSwJAfiC7BkAKG/EB8BzIMKWDID8R3IMOQAob8QNzjwZAChvxAdAmGFDDkB6JLMKSAIT8QXYIhBQz5gegSDClgyA9El2BIAUN+ILoEQwoY8gPRJRhSwJAfiC7BkAKG/EB0CYYUMOQHokswpIAhPxBdgiEFDPmBdaXtGIZhGEaJgaZpnGn8QP40GBIzgw2EIT8Q6xIMKWDID0SXYEgBQ34gugRDChjyA9ElGFLAkB+ILsGQAob8wP8BDkdYuhdw9UUAAAAASUVORK5CYII=" alt="" />

lpush(name,values)

 # 在name对应的list中添加元素,每个新的元素都添加到列表的最左边

 # 如:
# r.lpush('oo', ,,)
# 保存顺序为: ,, # 扩展:
# rpush(name, values) 表示从右向左操作
 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
r.lpush("oo",[,,])

lpushx(name,value)

 # 在name对应的list中添加元素,只有name已经存在时,值添加到列表的最左边

 # 更多:
# rpushx(name, value) 表示从右向左操作
 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
# r.lpush("oo",[,,])
r.lpush("oo",)

llen(name)

 # name对应的list元素的个数
 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
r.lpushx("oo",)
print(r.llen("oo"))

linsert(name, where, refvalue, value))

 # 在name对应的列表的某一个值前或后插入一个新值

 # 参数:
# name,redis的name
# where,BEFORE或AFTER
# refvalue,标杆值,即:在它前后插入数据
# value,要插入的数据

r.lset(name, index, value)

 # 对name对应的list中的某一个索引位置重新赋值

 # 参数:
# name,redis的name
# index,list的索引位置
# value,要设置的值

r.lrem(name, value, num)

 # 在name对应的list中删除指定的值

 # 参数:
# name,redis的name
# value,要删除的值
# num, num=,删除列表中所有的指定值;
# num=,从前到后,删除2个;
# num=-,从后向前,删除2个
 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)
r = redis.Redis(connection_pool=pool)
r.lrem("oo",,-)
print(r.llen("oo"))

常用操作:

delete(*names):根据删除redis中的任意数据类型

exists(name):检测redis的name是否存在

keys(pattern='*'):

 # 根据模型获取redis的name

 # 更多:
# KEYS * 匹配数据库中所有 key 。
# KEYS h?llo 匹配 hello , hallo 和 hxllo 等。
# KEYS h*llo 匹配 hllo 和 heeeeello 等。
# KEYS h[ae]llo 匹配 hello 和 hallo ,但不匹配 hillo

expire(name ,time):为某个redis的某个name设置超时时间

rename(src, dst): 对redis的name重命名为

move(name, db)): 将redis的某个值移动到指定的db下

randomkey():随机获取一个redis的name(不删除)

type(name): 获取name对应值的类型

scan(cursor=0, match=None, count=None)
scan_iter(match=None, count=None)

同字符串操作,用于增量迭代获取key

c:管道:

如果在redis操作中,执行多个命令的时候可以用pipline实现一次请求指定多个命令,并且默认情况下一次pipline 是原子性操作。

 import redis

 pool = redis.ConnectionPool(host='192.168.1.104', port=)

 r = redis.Redis(connection_pool=pool)

 pipe = r.pipeline(transaction=True)

 r.set('test', 'ok')
r.set('test1', 'cc')
print(r.get("test"))
print(r.get("test1")) pipe.execute()
b'ok'
b'cc'

d:发布订阅:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiwAAAECCAIAAABSWxtlAAAgAElEQVR4nO2deVhT17r/F/wenhPTNm2OzW1O5WDay7lFWj00CjIEZFIrIs4zDigOiGjFoY51blWcinWotrVOCFjFCURBRUBlnkUBQQYJ8xQgYeb3x8ZNSAIJrC0Jyfs+PPc55aafft1ruT559157b8Tn89sVqIaGhqamJkU+WVtbSy0QEuIDISE+EBLiAyEhP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ITgoQoAEJCfCAkxAdCQnwgJMQHgoTkFyTEB0JCfCAkxAdCQnyg0hP+f0Lir5f0IN+0AAAAAElFTkSuQmCC" alt="" />

小样:

#!/usr/bin/env python
# -*- coding:utf- -*- import redis class RedisHelper: def __init__(self):
self.__conn = redis.Redis(host='10.211.55.4')
self.chan_sub = 'fm104.5'
self.chan_pub = 'fm104.5' def public(self, msg):
self.__conn.publish(self.chan_pub, msg)
return True def subscribe(self):
pub = self.__conn.pubsub()
pub.subscribe(self.chan_sub)
pub.parse_response()
return pub

订阅者:

 #!/usr/bin/env python
# -*- coding:utf- -*- from monitor.RedisHelper import RedisHelper obj = RedisHelper()
redis_sub = obj.subscribe() while True:
msg= redis_sub.parse_response()
print msg

发布者:

 #!/usr/bin/env python
# -*- coding:utf- -*- from monitor.RedisHelper import RedisHelper obj = RedisHelper()
obj.public('hello')

更多redis和memcache 操作:http://www.cnblogs.com/wupeiqi/articles/5132791.html

多线程、多进程、协程、缓存(memcache、redis)的更多相关文章

  1. 多线程 多进程 协程 Queue(爬虫代码)

    快速理解多进程与多线程以及协程的使用场合和特点 首先我们来了解下python中的进程,线程以及协程! 从计算机硬件角度: 计算机的核心是CPU,承担了所有的计算任务.一个CPU,在一个时间切片里只能运 ...

  2. 也说性能测试,顺便说python的多进程+多线程、协程

    最近需要一个web系统进行接口性能测试,这里顺便说一下性能测试的步骤吧,大概如下 一.分析接口频率 根据系统的复杂程度,接口的数量有多有少,应该优先对那些频率高,数据库操作频繁的接口进行性能测试,所以 ...

  3. python 多进程,多线程,协程

    在我们实际编码中,会遇到一些并行的任务,因为单个任务无法最大限度的使用计算机资源.使用并行任务,可以提高代码效率,最大限度的发挥计算机的性能.python实现并行任务可以有多进程,多线程,协程等方式. ...

  4. 深入浅析python中的多进程、多线程、协程

    深入浅析python中的多进程.多线程.协程 我们都知道计算机是由硬件和软件组成的.硬件中的CPU是计算机的核心,它承担计算机的所有任务. 操作系统是运行在硬件之上的软件,是计算机的管理者,它负责资源 ...

  5. Python自动化 【第十篇】:Python进阶-多进程/协程/事件驱动与Select\Poll\Epoll异步IO

    本节内容: 多进程 协程 事件驱动与Select\Poll\Epoll异步IO   1.  多进程 启动多个进程 进程中启进程 父进程与子进程 进程间通信 不同进程间内存是不共享的,要想实现两个进程间 ...

  6. python进阶(二) 多进程+协程

    我们大多数的时候使用多线程,以及多进程,但是python中由于GIL全局解释器锁的原因,python的多线程并没有真的实现 实际上,python在执行多线程的时候,是通过GIL锁,进行上下文切换线程执 ...

  7. python中多进程+协程的使用以及为什么要用它

    前面讲了为什么python里推荐用多进程而不是多线程,但是多进程也有其自己的限制:相比线程更加笨重.切换耗时更长,并且在python的多进程下,进程数量不推荐超过CPU核心数(一个进程只有一个GIL, ...

  8. Python并发编程——多线程与协程

    Pythpn并发编程--多线程与协程 目录 Pythpn并发编程--多线程与协程 1. 进程与线程 1.1 概念上 1.2 多进程与多线程--同时执行多个任务 2. 并发和并行 3. Python多线 ...

  9. python单线程,多线程和协程速度对比

    在某些应用场景下,想要提高python的并发能力,可以使用多线程,或者协程.比如网络爬虫,数据库操作等一些IO密集型的操作.下面对比python单线程,多线程和协程在网络爬虫场景下的速度. 一,单线程 ...

  10. python3 - 多线程和协程速率测试对比

    多线程和协程都属于IO密集型,我通过以下用例测试多线程和协程的实际速率对比. 实例:通过socket客户端以多线程并发模式请求不同服务器端(这里服务器端分2种写法:第一种服务器通过协程实现,第二种服务 ...

随机推荐

  1. SpringMvc xml 配置

    <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" ...

  2. 下载SRA文件

    sratoolkit.2.6.2-centos_linux64/bin/prefetch  下载SRA文件 fastq-dump    --split-3    SRR2923014.sra    转 ...

  3. implicit operator

    class Digit { public Digit(double d) { val = d; } public double val; // ...other members // User-def ...

  4. js之oop <五>对象序列化(js的JSON操作)

    js对象序列化的过程,就是对象转换为JSON的过程.JSON.stringify() 将对象序列化成JSON.(接收对象,输出字符串) var obj = {x:2,y:3}; var str = J ...

  5. php总结 --- 2.字符串

    字符串 恩聪 正则表达式 恩聪 中文验证 if (preg_match("/[\x{4e00}-\x{9fa5}]{2,4}\s{0,}\w{8,15}/u", $keyword) ...

  6. Mac下安装Wireshark,双击闪退

     Mac OS X上使用Wireshark抓包(http://blog.csdn.net/phunxm/article/details/38590561) Mac下安装Wireshark /Appli ...

  7. 【ros】rplidar Hector Slam

    想用rplidar跑一下hector slam,在网上发现了几个教程写的都不错,但是亲测发现都有点不足,综合了一下,进行补充. 1. 安装ros 和 创建工作空间 http://blog.csdn.n ...

  8. 【转】 CPU大小端

    大端模式,是指数据的低位保存在内存的高地址中,而数据的高位,保存在内存的低地址中:小端模式,是指数据的低位保存在内存的低地址中,而数据的高位保存在内存的高地址中. 为什么会有大小端模式之分呢?这是因为 ...

  9. IntelliJ IDEA 设置代码提示或自动补全的快捷键

    IntelliJ IDEA 设置代码提示或自动补全的快捷键   点击 文件菜单(File) –> 点击 设置(Settings- Ctrl+Alt+S), –> 打开设置对话框. 在左侧的 ...

  10. 《转》简述c语言的优缺点

    C语言是1972年由美国的Dennis Ritchie设计发明的,到1978年由美国电话电报公司(AT&T)贝尔实验室正式发表了C语言.再到1970到80年代,C语言被广泛应用.这短短的几十年 ...