python库之threading
This module constructs higher-level threading interfaces on top of the lower level python库之_thread
module
官方参考文档:https://docs.python.org/2/library/threading.html
threading库对象和方法
(1)threading.active_count()
(2)theading.Condition()
A factory function that returns a new condition variable object,See Condition Objects.
(3)threading.current_thread()
(4)threading.enumerate()
Return a list of all Thread
objects currently alive. The list includes daemonic threads, dummy thread objects created by current_thread()
, and the main thread. It excludes terminated threads and threads that have not yet been started.
(5)threading.event()
A factory function that returns a new event object. An event manages a flag that can be set to true with the set()
method and reset to false with the clear()
method. The wait()
method blocks until the flag is true.See Event Objects.
(6)class threading.local
A class that represents thread-local data. Thread-local data are data whose values are thread specific. To manage thread-local data, just create an instance of local
(or a subclass) and store attributes on it:
mydata = threading.local()
mydata.x = 1
The instance’s values will be different for separate threads.
For more details and extensive examples, see the documentation string of the _threading_local
module.
(7)theading.Lock()
A factory function that returns a new primitive lock object. Once a thread has acquired it, subsequent attempts to acquire it block, until it is released; any thread may release it.See Lock Objects.
(8)threading.RLock()
A factory function that returns a new reentrant lock object. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it.See RLock Objects.
(9)threading.Semaphore([value])
A factory function that returns a new semaphore object. A semaphore manages a counter representing the number of release()
calls minus the number of acquire()
calls, plus an initial value. The acquire()
method blocks if necessary until it can return without making the counter negative. If not given, value defaults to 1.See Semaphore Objects.
(10)threading.BoundedSemaphore([value])
A factory function that returns a new bounded semaphore object. A bounded semaphore checks to make sure its current value doesn’t exceed its initial value. If it does, ValueError
is raised. In most situations semaphores are used to guard resources with limited capacity. If the semaphore is released too many times it’s a sign of a bug. If not given, value defaults to 1.
(11)class threading.Thread
A class that represents a thread of control. This class can be safely subclassed in a limited fashion.See Thread Objects.
(12)class threading.Timer
A thread that executes a function after a specified interval has passed.See Timer Objects.
(13)threading.settrace(func)
(14)threading.setprofile(func)
(15)threading.stack_size([size])
python库之threading的更多相关文章
- Python 库大全
作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...
- 哪些 Python 库让你相见恨晚?【转】
原文链接:https://www.zhihu.com/question/24590883/answer/92420471 原文链接:Python 资源大全 ---------------- 这又是一个 ...
- Python库资源大全
转载地址:https://zhuanlan.zhihu.com/p/27350980 本文是一个精心设计的Python框架.库.软件和资源列表,是一个Awesome XXX系列的资源整理,由BigQu ...
- Python库,让你相见恨晚的第三方库
环境管理 管理 Python 版本和环境的工具 p – 非常简单的交互式 python 版本管理工具.pyenv – 简单的 Python 版本管理工具.Vex – 可以在虚拟环境中执行命令.virt ...
- Python 库,资源
库名称简介 Chardet字符编码探测器,可以自动检测文本.网页.xml的编码. colorama主要用来给文本添加各种颜色,并且非常简单易用. Prettytable主要用于在终端或浏览器端构建格式 ...
- Python资源 --Python库
环境管理 管理 Python 版本和环境的工具 pyenv – 简单的 Python 版本管理工具. Vex – 可以在虚拟环境中执行命令. virtualenv – 创建独立 Python 环境的工 ...
- python 库资源大全
偶然的机会翻到这篇文章,很全面,来源: Python 资源大全中文版 哪些 Python 库让你相见恨晚? 环境管理 管理 Python 版本和环境的工具 p:非常简单的交互式 pyth ...
- Python库大全
网络 urllib -网络库(stdlib). requests -网络库. grab – 网络库(基于pycurl). pycurl – 网络库(绑定libcurl). urllib3 – Pyth ...
- Python 库汇总中文版
这又是一个 Awesome XXX 系列的资源整理,由 vinta 发起和维护.内容包括:Web框架.网络爬虫.网络内容提取.模板引擎.数据库.数据可视化.图片处理.文本处理.自然语言处理.机器学习. ...
随机推荐
- 【JavaScript】下大雪
引用[JavaScript]满天星的代码,稍作修改的结果: function drawStars() { for (i = 1; i < 100; ++i) { ctx.fillText(&qu ...
- jQuery图片列表拖拽排序布局
在线演示 本地下载
- 文件(1)--File
File简介 Java.io.File用于表示文件(目录),也就是说程序员可以通过File类在程序中操作硬盘上的文件和目录.File类只用于表示文件(目录)的信息(名称.大小等),不能对文件的内容进行 ...
- codevs 1017 乘积最大 dp
1017 乘积最大 时间限制: 1 s 空间限制: 128000 KB 题目描述 Description 今年是国际数学联盟确定的“2000——世界数学年”,又恰逢我国著名数学家华罗庚 ...
- Java中的逻辑运算符
逻辑运算符主要用于进行逻辑运算.Java 中常用的逻辑运算符如下表所示: 我们可以从“投票选举”的角度理解逻辑运算符: 1. 与:要求所有人都投票同意,才能通过某议题 2. 或:只要求一个人投票同意就 ...
- scala学习手记35 - 隐式类型转换
先来看一下下面的内容: 2 days "ago" 5 days "from_now" 如上的内容具体应该是什么呢?不过怎么看也不像是代码.不过既然是在学代码,拿 ...
- 论Spark高手是怎样炼成的
SPARK J大数据的处理怎么能变快一点,答案是请用spark,因为它是基于内存的,可以有效减少数据的落地次数.Spark性能超过Hadoop百倍,从多迭代批量处理出发,兼收并蓄数据仓库.流处理和图计 ...
- 新东方雅思词汇---8.2、chron
新东方雅思词汇---8.2.chron 一.总结 一句话总结:时间 chronic 英 ['krɒnɪk] 美 ['krɑnɪk] adj. 慢性的:长期的:习惯性的 n. (Chronic)人名 ...
- 第11章:最长公共子序列(LCS:Longest Common Subsequence)
方法:动态规划 <算法导论>P208 最优子结构 + 重叠子问题 设xi,yi,为前i个数(前缀) 设c[i,j]为xi,yi的LCS的长度 c[i,j] = 0 (i ==0 || j ...
- 解决:TypeError: object() takes no parameters
运行测试用例时发现以下报错 Ran 1 test in 22.505s FAILED (errors=1) Error Traceback (most recent call last): File ...