上一页 1 2 3 4 5 6 7 ··· 13 下一页

2019年1月14日

摘要: from multiprocessing import Process,Queue def f1(q): q.put('约吗?') if __name__ == '__main__': q = Queue(3) p = Process(target=f1,args=(q,)) p.start() son_p_msg = q.get() p... 阅读全文

posted @ 2019-01-14 16:05 缥缈映苍穹 阅读(92) 评论(0) 推荐(0)

摘要: import time from multiprocessing import Process,Queue #生产者 def producer(q): for i in range(10): time.sleep(0.2) s = '大包子%s号'%i print(s+'新鲜出炉,拿去用') q.put(s) q.p... 阅读全文

posted @ 2019-01-14 16:04 缥缈映苍穹 阅读(124) 评论(0) 推荐(0)

摘要: import time from multiprocessing import Process,Queue #生产者 def producer(q): for i in range(10): time.sleep(0.7) s = '大包子%s号'%i print(s+'新鲜出炉,拿去用') q.put(s) def c... 阅读全文

posted @ 2019-01-14 16:03 缥缈映苍穹 阅读(240) 评论(0) 推荐(0)

摘要: import time from multiprocessing import Process def f1(): time.sleep(0.5) print('xxx') if __name__ == '__main__': p_list = [] #for循环创建子进程,并且完成主进程等待所有子进程执行结束,才继续执行 for i in rang... 阅读全文

posted @ 2019-01-14 16:02 缥缈映苍穹 阅读(78) 评论(0) 推荐(0)

摘要: import time from multiprocessing import Process,Manager,Lock # a = 10 # # tmp = a # # tmp -= 1 # # a = tmp # a -= 1 # a = a - 1 def f1(m_d,l2): # m_d['num'] -= 1 # with l2: # l2.a... 阅读全文

posted @ 2019-01-14 16:01 缥缈映苍穹 阅读(93) 评论(0) 推荐(0)

摘要: # 互斥锁/进程锁/同步锁 # import json import time from multiprocessing import Process,Lock def show_t(i): with open('ticket','r',encoding='utf-8') as f: ticket_data = f.read() # print(ticket_... 阅读全文

posted @ 2019-01-14 15:57 缥缈映苍穹 阅读(114) 评论(0) 推荐(0)

摘要: from multiprocessing import Process,Queueq = Queue(3) #创建一个队列对象,队列长度为3,先进先出q.put(1)# print(">>>>",q.qsize()) #返回当前队列的内容长度print(q.full())q.put(2)# prin 阅读全文

posted @ 2019-01-14 15:56 缥缈映苍穹 阅读(116) 评论(0) 推荐(0)

摘要: import time from multiprocessing import Process def f1(): time.sleep(3) print("xxxx") def f2(): time.sleep(5) print("普通子进程的代码") if __name__ == '__main__': p = Process(target=f1... 阅读全文

posted @ 2019-01-14 15:55 缥缈映苍穹 阅读(124) 评论(0) 推荐(0)

摘要: from multiprocessing import Process num = 100 def f1(): global num num = 3 print("子进程中的num",num) print(">>>>",num) if __name__ == '__main__': p = Process(target=f1,) p.start() ... 阅读全文

posted @ 2019-01-14 15:52 缥缈映苍穹 阅读(202) 评论(0) 推荐(0)

摘要: import time import os from multiprocessing import Process def f1(): print("子进程的pid",os.getpid()) print("子进程的父进程pid",os.getpid()) print("aaa") def f2(): print("bbb") # if __name__ == ... 阅读全文

posted @ 2019-01-14 15:52 缥缈映苍穹 阅读(101) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 13 下一页