官方参考文档: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的更多相关文章

  1. python库之threading

    This module constructs higher-level threading interfaces on top of the lower level python库之_threadmo ...

  2. 11个并不广为人知,但值得了解的Python库

    这是一篇译文,文中提及了一些不常见但是有用的Python库 原文地址:http://blog.yhathq.com/posts/11-python-libraries-you-might-not-kn ...

  3. python自动化测试(4)-使用第三方python库技术实现

    python自动化测试(4)-使用第三方python库技术实现 1   概述 关于测试的方法论,都是建立在之前的文章里面提到的观点: 功能测试不建议做自动化 接口测试性价比最高 接口测试可以做自动化 ...

  4. OSX下 pip更新及安装python库

    直接执行安装命令 $ pip install builtwith 提示pip当前版本为7.1.2,要使用"pip install --upgrade pip"升级到8.1.2 $  ...

  5. protocol buffer c++ python库安装

    c++库安装较简单,不要用源码,还得下载依赖,就被墙了 https://github.com/google/protobuf/releases  下载一个最新的release安装 #protoc -- ...

  6. Windows版的各种Python库安装包下载地址与安装过程

    在用Python开发时(Windows环境),会碰到需要安装某个版本的第三方库,为了以后查找.安装方便,总结如下: windows版的各种Python库安装包下载地址:http://www.lfd.u ...

  7. python 线程之_thread

    python 线程之_thread _thread module: 基本用法: def child(tid): print("hello from child",tid) _thr ...

  8. Python 库大全

    作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...

  9. python库tkinter、pygame中几点需要注意的问题

    恍然之间已经16年快四月份了,已经好久都没有写过东西了.. 最近在用python做一些小的游戏,在网上找了一些Python库,Python中游戏编程最常用的还是pygame了,其次是Tkinter p ...

随机推荐

  1. LigerUI LigerGird IE7/8 下不显示 “in”的操作数无效

    LigerUI IE7/8 下显示 in的操作数无效 修改脚本生成LigerGrid的地方,将最后一列后面的,去掉

  2. Django学习笔记之Django中间件

    准备 我们在前面的课程中已经学会了给视图函数加装饰器来判断是用户是否登录,把没有登录的用户请求跳转到登录页面.我们通过给几个特定视图函数加装饰器实现了这个需求.但是以后添加的视图函数可能也需要加上装饰 ...

  3. 开源流量分析系统 Apache Spot 概述(转)

    原文地址http://blog.nsfocus.net/apache-spot/ Apache Spot 是一个基于网络流量和数据包分析,通过独特的机器学习方法,发现潜在安全威胁和未知网络攻击能力的开 ...

  4. Linux常用命令--文件(夹)查找之find命令

    Linux系统用得越久,就会发现这真的是一个很优秀的系统,各种方便各种实用各种高效率. 晚饭前写一下find命令的笔记. 其实这篇笔记,也是看到一篇外文博客,写得不错,自己拿来练一练,然后才顺便写篇笔 ...

  5. 汇编指令与Intrinsics指令的对应关系汇总

    汇编指令与Intrinsics指令的对应关系汇总 参考网址:https://software.intel.com/sites/landingpage/IntrinsicsGuide/ 1.赋值指令:m ...

  6. 使用node-inspector调试NodeJS代码

    使用node-inspector调试NodeJS代码 任何一门完备的语言技术栈都少不了健壮的调试工具,对于NodeJS平台同样如此,笔者研究了几种调试NodeJS代码的方式,通过对比,还是觉得node ...

  7. TCP/UDP编程步骤和区别

    一. 概念解析 套接字:一种特殊的文件描述符.一头指向套接字地址(用户),一头指向套接字结构(内核). 套接字结构:由内核维持的一种数据结构,可通过套接字来操作. 套接字地址:ip和port. 二. ...

  8. samba配置只读和可以写入的共享

    编辑smb.conf 1.在[global]中 找到 security = 将其改为 security = share 2. 在文件中加入自定义的共享目录 [attachment] path=/dat ...

  9. ARM汇编指令集5

    为什么需要多寄存器访问指令? ldr/str每周期只能访问4字节内存,如果需要批量读取.写入内存时太慢,解决方案是stm/ld 举例(uboot start.S 537行)   stmia  sp, ...

  10. 剑指offer--25.二叉树的镜像

    时间限制:1秒 空间限制:32768K 热度指数:238655 题目描述 操作给定的二叉树,将其变换为源二叉树的镜像. 输入描述: 二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 ...