Python3 Queue (one-way queue) detailed description

Source: Internet
Author: User
Create a queue


Import Queueq = queue. Queue ()

Empty (returns True if the queue is empty)


Import Queueq = queue. Queue () print (Q.empty ()) #输出: True

Full (returns True if the queue is filled)


Import Queueq = queue. Queue (1) #指定队列大小q. Put (' a ') print (Q.full ()) #输出: True

Put (put an element into the queue) get (take an element out of a queue) FIFO principle


Import Queueq = queue. Queue () q.put (' A ') q.put (' B ') print (Q.get ()) #输出: A

Get_nowait (immediately remove an element without waiting)


#占位

Put_nowait (immediately put an element, do not wait)


#占位

Join (blocks the calling thread until all tasks in the queue are processed)


#占位

Qsize (returns the number of elements in the queue)


Import Queueq = queue. Queue () q.put (' A ') q.put (' B ') print (Q.qsize ()) #输出: 2

Task_done (after completing a task, send a signal to the queue that the task has completed)


#占位

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.