官方参考文档: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. SSDB系列文章推荐

    1. 下载和安装: http://ssdb.io/docs/zh_cn/install.html 2. SSDB 文档     http://ssdb.io/docs/zh_cn/index.html ...

  2. Django-JS实现的ajax

    JS实现的ajax ajax的优缺点 AJAX使用Javascript技术向服务器发送异步请求 AJAX无须刷新整个页面 因为服务器响应内容不再是整个页面,而是页面中的局部,所以AJAX性能高 小练习 ...

  3. WIN7下PHP无法开启CURL,终极解决方案

    常规做法: 1)extension=php_curl.dll之外 2)把libeay32.dll.ssleay32.dll.php_curl.dll复制到C:\Windows\SysWOW64目录下 ...

  4. Linux下针对路由功能配置iptables的方法详解

    作为公司上网的路由器需要实现的功能有nat地址转换.dhcp.dns缓存.流量控制.应用程序控制,nat地址转换通过iptables可以直 接实现,dhcp服务需要安装dhcpd,dns缓存功能需要使 ...

  5. 编程练习赛11B 物品价值(装压dp)

    题意:每个物品有m(m<=10)种属性和一个价格,你有n种物品从中任意选择一些物品,让每种属性恰好有奇数个物品拥有,输出满足条件的最大价值和 题解:一看就是明显的01背包问题,但是价格乘以个数的 ...

  6. eclipse官网下载

    Provided by IBM Cloud Eclipse IDE for Java Developers http://eclipse.bluemix.net/packages/photon/dat ...

  7. linux top ps 命令

    http://javawind.net/p131 VIRT:virtual memory usage 虚拟内存1.进程“需要的”虚拟内存大小,包括进程使用的库.代码.数据等2.假如进程申请100m的内 ...

  8. Codeforces Beta Round #17 D.Notepad 指数循环节

    D. Notepad time limit per test 2 seconds memory limit per test 64 megabytes input standard input out ...

  9. Java 如何解析由String类型拼接的XML格式

    String xml = new String(a);打印的xml 的值是 <?xml version= 1.0 encoding=gb2312?><weighData>< ...

  10. python学习笔记(unittest)

    刚刚放假回来我想很多人都还没有缓过来吧 这次介绍一个python自带的测试框架 unitest #!/usr/bin/env python # -*- coding: utf_8 -*- import ...