Python教程

python 进程间利用queue 传递参数

本文主要是介绍python 进程间利用queue 传递参数,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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()

 

这篇关于python 进程间利用queue 传递参数的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!