如何通过线程将队列引用传递到另一个文件中的函数

2024-09-30 22:11:23 发布

您现在位置:Python中文网/ 问答频道 /正文

在importreftest.py在

import importreftest2
import Queue
import threading

q= Queue.Queue(maxsize=0)

q.put(1)
q.put(2)
q.put("hello")

print "here"

t = threading.Thread(target = importreftest2.trythis, args = q)
t.start()

在importreftest2.py中

^{pr2}$

跑步时importreftest.py“trythis”没有打印,队列中也没有任何内容


Tags: pyimporthellotargetherequeueputargs