python库之_thread
官方参考文档:https://docs.python.org/3.7/library/_thread.html
_thread库方法
(1) _thread.error
(2)_thread.LockTyoe
(3)_thread.start_new_thread
(4)_thread.interrupt_main
Raise a KeyboardInterrupt exception in the main thread. A subthread can use this function to interrupt the main thread.
(5)_thread.exit
(6)_thread.allocate_lock
import _thread a_lock = _thread.allocate_lock() with a_lock:
print("a_lock is locked while this executes")
(7)_thread.get_ident
(8)_thread.stack_size
(9)_thread.TIMEOUT_MAX
(10)lock.acquire(waitflag=1,timeout=-1)
Without any optional argument, this method acquires the lock unconditionally, if necessary waiting until it is released by another thread (only one thread at a time can acquire a lock — that’s their reason for existence).
If the integer waitflag argument is present, the action depends on its value: if it is zero, the lock is only acquired if it can be acquired immediately without waiting, while if it is nonzero, the lock is acquired unconditionally as above.
If the floating-point timeout argument is present and positive, it specifies the maximum wait time in seconds before returning. A negative timeout argument specifies an unbounded wait. You cannot specify a timeout if waitflag is zero.
The return value is True if the lock is acquired successfully, False if not.
(11)lock.release()
(12)lock.locked()
python库之_thread的更多相关文章
- python库之threading
This module constructs higher-level threading interfaces on top of the lower level python库之_threadmo ...
- 11个并不广为人知,但值得了解的Python库
这是一篇译文,文中提及了一些不常见但是有用的Python库 原文地址:http://blog.yhathq.com/posts/11-python-libraries-you-might-not-kn ...
- python自动化测试(4)-使用第三方python库技术实现
python自动化测试(4)-使用第三方python库技术实现 1 概述 关于测试的方法论,都是建立在之前的文章里面提到的观点: 功能测试不建议做自动化 接口测试性价比最高 接口测试可以做自动化 ...
- OSX下 pip更新及安装python库
直接执行安装命令 $ pip install builtwith 提示pip当前版本为7.1.2,要使用"pip install --upgrade pip"升级到8.1.2 $ ...
- protocol buffer c++ python库安装
c++库安装较简单,不要用源码,还得下载依赖,就被墙了 https://github.com/google/protobuf/releases 下载一个最新的release安装 #protoc -- ...
- Windows版的各种Python库安装包下载地址与安装过程
在用Python开发时(Windows环境),会碰到需要安装某个版本的第三方库,为了以后查找.安装方便,总结如下: windows版的各种Python库安装包下载地址:http://www.lfd.u ...
- python 线程之_thread
python 线程之_thread _thread module: 基本用法: def child(tid): print("hello from child",tid) _thr ...
- Python 库大全
作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...
- python库tkinter、pygame中几点需要注意的问题
恍然之间已经16年快四月份了,已经好久都没有写过东西了.. 最近在用python做一些小的游戏,在网上找了一些Python库,Python中游戏编程最常用的还是pygame了,其次是Tkinter p ...
随机推荐
- html 基础--一般标签
<html> --开始标签 <head> 网页上的控制信息 <title>页面标题</title> </head> <body& ...
- LigerUI v1.2.4 LigerGrid 横轴滚动条
1.设置隐藏列的宽度,不要等于0 2.设置body样式添加overflow: hidden;
- Mybatis中的ParameterType
mybatis可以传入的参数类型1.基本数据类型 可以通过#{参数名}直接获取.每次只能传入一个值 <select id="selectTeacher" ...
- redis安装优化:
1)内存分配控制: vm.overcommit_memoryredis启动时肯呢个会出现这样的日志: :M Apr ::! Background save may fail under low mem ...
- <关于并发框架>Java原生线程池原理及Guava与之的补充
原创博客,转载请联系博主! 转眼快两个月没有更新自己的博客了. 一来感觉自己要学的东西还是太多,与其花几个小时写下经验分享倒不如多看几点技术书. 二来放眼网上已经有很多成熟的中文文章介绍这些用法,自己 ...
- java中线程状态-死亡
线程死亡: 线程会以如下3种方式结束,结束后就处于死亡状态. 1.run()或call()方法执行完成,线程正常结束. 2.线程抛出一个未捕获的Exception或Error 3.直接调用该线程的st ...
- 平滑重启php
kill -USR2 `cat /usr/local/webserver/php/var/run/php-fpm.pid`
- python基础8 - 变量2
1. 变量的引用 变量 和 数据 都是保存在 内存 中的 在 Python 中 函数 的 参数传递 以及 返回值 都是靠 引用 传递的 1.1 引用的概念 在 Python 中 变量 和 数据 是分开 ...
- Java class、Object、Class 的区别
Java的对象模型中: 所有的类都是Class类的实例,Object是类,那么Object也是Class类的一个实例. 所有的类都最终继承自Object类,Class是类,那么Class也继承自Obj ...
- 深入理解Lambda
概述 Lambda是一个表达式,也可以说它是一个匿名函数.然而在使用它或是阅读Lambda代码的时候,却显得并不那么容易.因为它匿名,因为它删减了一些必要的说明信息(比如方法名).下面就来说说Lamb ...