Python Queueの詳細

806 ワード

#FIFO  
import queue
q=queue.Queue(3)  #    3     

#  put          ,            
#      ,     (block=True),           (timeout=5)
#    block=False         
q.put(11)
q.put(22)
q.put(33)
print(q.empty())  #        ,      False,     True
print(q.qsize())  #         
q.put(44,block=True,timeout=5)



#  get         ,              
#       ,     (block=True),           (timeout=2)
#    block=False         
print(q.get())
print(q.get())
print(q.get())
print(q.get(block=True,timeout=2))


#    join task_done  ,           
#join               ,          ,    
#                 ?  task_done                   
que=queue.Queue(3)  #    3       
que.put(11)
que.put(22)
que.put(33)

que.get()
que.task_done()  #                
que.get()
que.task_done()  #                

que.join()