开发者

python: subprocess.call threads problem

开发者 https://www.devze.com 2023-02-13 14:42 出处:网络
Hello people within the while True processing never ends, even if I use q.task_done, what is wrong? fileQueue = Queue()

Hello people within the while True processing never ends, even if I use q.task_done, what is wrong?


fileQueue = Queue()
def submit(i, q):
    global filespath
    while True:
      filename = q.get()
      retVT = subprocess.call("python abc.py -f %s" % (filespath + filename), shell=True, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
      retTH = subprocess.call("python def.py -a %s" % (filename), shell= True, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
      q.task_done()

def main(): global fileQueue

开发者_Python百科num_threads = fileQueue.qsize() for i in range(num_threads): worker = Thread(target=submit, args=(i, fileQueue)) worker.setDaemon(True) worker.start() fileQueue.join()

print "Done"

if name == 'main': main()

Thanks


What are the program listings for abc.py and def.py? Are you sure that the commands you are executing ever end? Try running it with the two subprocess.call() lines commented out and see if it works as intended. If it suddenly works, then the problem is somewhere related to the scripts you're calling outside of the code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号