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()
in importreftest2.py
def trythis(q):
print "trythis"
while True:
if not q.empty():
print q.get()
当运行importreftest.py时,不会打印“trythis”,也不会打印队列中的任何内容