0
点赞
收藏
分享

微信扫一扫

python 进程间利用queue 传递参数

何晓杰Dev 2022-05-18 阅读 26
from multiprocessing import Process

def chulibkk(bka,q):
global connect,con
for acc in acca:
result=[]
aty=str(acc["rootId"])
userid=str(acc['userId'])
q.put(userid)

def wm0323(q):
global con,connect
while 1:
sql2="select bk from bkdxy where zg<>'2' ORDER BY RAND() LIMIT 5 "
aa=get_one(sql2)
sql3="update bkdxy set zg='1' where bk={}".format(aa[0])
zxupdate(sql3)
#aa=("64",)
chulibkk(aa[0],q)
sql3="update bkdxy set zg='2' where bk={}".format(aa[0])
zxupdate(sql3)

def wm0324(q):
global con,connect
while 1:
if not q.empty():
va=q.get(True)
print(va)
if jiancea(va)==0:
chulixx(va)
if __name__=='__main__':
global connect,con
q = Queue()
pw = Process(target=wm0323, args=(q,))
pr = Process(target=wm0324, args=(q,))
## pw1 = Process(target=wm0323, args=(q,))
## pw1.start()
pw.start()
pr.start()
## pw1.join()
pw.join()
pr.join()





举报

相关推荐

0 条评论