后浪云Python教程:python threading模块有哪些函数
1、说明
python提供的与线程操作相关的模块,在3.x版本中使用threading代替thread,如果想在python2.x版本中使用threading,则可以使用dumy_threading模块。
2、threading模块提供的可直接调用的函数
-
active_count():获取当前活跃(alive)线程的个数。
-
current_thread():获取当前的线程对象。
-
get_ident():返回当前线程的索引,一个非零的整数(3.3新增)。
-
enumerate():获取当前所有活跃线程的列表。
-
main_thread():返回主线程对象(3.4新增)。
-
settrace(func):设置一个回调函数,在run()执行之前被调用。
-
setprofile(func):设置一个回调函数,在run()执行完毕之后调用。
-
stack_size():返回创建新线程时使用的线程堆栈大小。
-
threading.TIMEOUT_MAX:堵塞线程时间值,超过这个值会栈溢出。
以上就是python threading模块中函数的介绍,希望对大家有所帮助。更多Python学习指路:后浪云python教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
版权声明:
作者:后浪云
链接:https://www.idc.net/help/174805/
文章版权归作者所有,未经允许请勿转载。
THE END