以下是来源:
#one.py:
from Queue import Queue
req = Queue()
#two.py:
import one
import time
if __name__ == '__main__':
while True:
print "this is two.py and reqID is ",id(one.req)
print "Queue size is %s"%one.req.qsize()
time.sleep(5)
#three.py:
import one
import time
if __name__ == '__main__':
while True:
print "this is three.py and reqID is ",id(one.req)
print "Queue size is %s"%one.req.qsize()
one.req.put(2)
time.sleep(5)
one.py
有一个共同的队列。我想使用two.py
和three.py
控制one.py
的公共队列。