进程间通信IPC机制

#管道
#队列=管道+锁
from multiprocessing import Queue

# q=Queue()
# q.put([‘first‘,])
# q.put({‘x‘:2})
# q.put(3)
# # q.put(4)
#
# print(q.get())
# print(q.get())
# print(q.get())
# print(q.get())

# 了解:
q=Queue(3)
# q.put([‘first‘,],block=True,timeout=3)
# q.put({‘x‘:2},block=True,timeout=3)
# q.put(3,block=True,timeout=3)
# q.put(4,block=True,timeout=3)

q.put_nowait(1) #q.put(1,block=False)
q.put_nowait(2)
q.put_nowait(3)
# q.put_nowait(4)

# print(q.get(block=True,timeout=3))
# print(q.get(block=True,timeout=3))
# print(q.get(block=True,timeout=3))
# print(q.get(block=True,timeout=3))

print(q.get_nowait()) #q.get(block=false)
print(q.get_nowait()) #q.get(block=false)
print(q.get_nowait()) #q.get(block=false)
print(q.get_nowait()) #q.get(block=false)

 

进程间通信IPC机制

上一篇:Ubuntu18.04.5 server wifi的连接


下一篇:记录linux LVM 扩容硬盘空间的记录