https://docs.python.org/3.6/library/queue.html

https://github.com/python/cpython/blob/3.6/Lib/queue.py

The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics. It depends on the availability of thread support in Python; see the threading module.

The module implements three types of queue, which differ only in the order in which the entries are retrieved. In a FIFO queue, the first tasks added are the first retrieved. In a LIFO queue, the most recently added entry is the first retrieved (operating like a stack). With a priority queue, the entries are kept sorted (using the heapq module) and the lowest valued entry is retrieved first.

Internally, the module uses locks to temporarily block competing threads; however, it is not designed to handle reentrancy within a thread.

The queue module defines the following classes and exceptions:

class queue.Queue(maxsize=0)

Constructor for a FIFO queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.

class queue.LifoQueue(maxsize=0)

Constructor for a LIFO queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.

class queue.PriorityQueue(maxsize=0)

Constructor for a priority queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.

The lowest valued entries are retrieved first (the lowest valued entry is the one returned by sorted(list(entries))[0]). A typical pattern for entries is a tuple in the form: (priority_number, data).

exception queue.Empty

Exception raised when non-blocking get() (or get_nowait()) is called on a Queue object which is empty.

exception queue.Full

Exception raised when non-blocking put() (or put_nowait()) is called on a Queue object which is full.

最新文章

  1. 如何在ASP.NET Core中应用Entity Framework
  2. 解决select2在bootstrap的modal中默认不显示的问题
  3. C# 时间比较大小
  4. jQuery遮罩层效果
  5. 修改开机启动等待时间(for Ubuntu12.10)
  6. Maven - 项目结构
  7. 核心思想:早胜过一切,张小龙的Foxmail居然可以卖1200万
  8. linux下查看磁盘空间
  9. HTML学习笔记四
  10. unity getcomponentsinchildren 翻船
  11. AWS-SS配置过程
  12. asp.net的Request.ServerVariables参数说明
  13. python监控机器(第1版)
  14. python基础day3
  15. 初步了解.net
  16. 洛谷P4316 绿豆蛙的归宿
  17. 团体程序设计天梯赛(CCCC) L3009 长城 方法证明
  18. 【优秀的Sketch插件】PaintCode for Sketch for Mac 1.1
  19. wx小程序-音频视频!
  20. vue错误记录

热门文章

  1. 刷题总结——bzoj2243染色
  2. 做运动(Dijkstra+并查集+MST)
  3. spring security 登录、权限管理配置
  4. 手动实现jQuery的toggle()效果
  5. msp430项目编程50
  6. shell的select脚本的简单入门
  7. Spring 3.0 注解
  8. spring boot -- 无法读取html文件,碰到的坑
  9. 实现TTCP (检测TCP吞吐量)
  10. IO重定向