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 ...
随机推荐
- MiniGUI 显示中文
修改/usr/local/etc/MiniGUI.cfg # The first system font must be a logical font using RBF device font.[s ...
- c#基础-自动内存管理
1.自动垃圾回收是什么? 在非托管环境下程序员要自已管理内存,由疏忽的原因,通常会犯两种错误,请求内存后在不使用时忘记释放,或使用已经释放了的内存.但在托管环境下,程序员不用担心这两个问题,C ...
- js算法-快速排序(Quicksort)
快速排序(英语:Quicksort),又称划分交换排序(partition-exchange sort),简称快排,一种排序算法,最早由东尼·霍尔提出.在平均状况下,排序n个项目要O(nLogn)次比 ...
- 物理机内存模型与java内存模型
多线程缓存一致性问题 程序在运行过程中,会将运算需要的数据从主存复制一份到CPU的高速缓存当中,那么CPU进行计算时就可以直接从它的高速缓存读取数据和向其中写入数据,当运算结束之后,再将高速缓存中的数 ...
- java.lang.ClassNotFoundException: org.apache.commons.discovery.tools.DiscoverSingleton
java.lang.ClassNotFoundException: org.apache.commons.discovery.tools.DiscoverSingleton org.apache.ax ...
- NGINX的IO模型详解
普及: 用户空间与内核空间: 现在操作系统都是采用虚拟存储器,那么对32位操作系统而言,它的寻址空间(虚拟存储空间)为4G(2的32次方).操作系统的核心是内核,独立于普通的应用程序,可以访问受保护的 ...
- 什么是Zero-Copy?
概述 考虑这样一种常用的情形:你需要将静态内容(类似图片.文件)展示给用户.那么这个情形就意味着你需要先将静态内容从磁盘中拷贝出来放到一个内存buf中,然后将这个buf通过socket传输给用户,进而 ...
- jsp select multiple
//File: index.html<HTML> <HEAD> <TITLE>Submitting Multiple Selection Sel ...
- [POI2006]MET-Subway
Description 给出一棵N个结点的树,选择L条路径,覆盖这些路径上的结点,使得被覆盖到的结点数最多. Input 第一行两个正整数N.L(2 <= N <= 1,000,000, ...
- Java对象初始化
自动初始化(默认值) 一个类的所有基本数据成员都会得到初始化,运行下面的例子可以查看这些默认值: class Default{ boolean t; char c; byte b; short s; ...