Python RuntimeError: thread.__init__() not called解决方法
作者:junjie 时间:2022-12-22 17:11:46
在写一个多线程类的时候调用报错
RuntimeError: thread.__init__() not called
class NotifyTread(threading.Thread):
def __init__(self, params):
threading.Thread.__init__(self) #here。。。。。。
self.params = params
def run(self):
print "start notify............"
time.sleep(10)
print notify_tran(self.params)
print "end notify.............."
在init中要先初始化Thread,然后在给参数赋值,就能解决了。
也就是不能缺少
threading.Thread.__init__(self)
这是一个使用的注意地方。
标签:Python,RuntimeError,thread.,init,(),not,called
0
投稿
猜你喜欢
python中getattr函数使用方法 getattr实现工厂模式
2021-02-25 00:34:30
python脚本爬取字体文件的实现方法
2022-09-07 18:20:55
Symfony2之session与cookie用法小结
2023-11-22 02:58:30
Python函数默认参数设置的具体方法
2021-03-13 08:19:07
使用Python实现将list中的每一项的首字母大写
2023-01-07 15:05:04
自定义asp错误信息的显示
2007-09-13 12:33:00
python设置Pyplot的动态rc参数、绘图的填充
2023-12-15 22:52:29
asp如何用ADO批量更新记录?
2010-06-10 18:42:00
numba提升python运行速度的实例方法
2022-10-06 20:39:27
品牌的统一体验
2010-05-19 13:08:00
python做图片搜索引擎并保存到本地详情
2021-08-27 01:42:33
Python 一键获取百度网盘提取码的方法
2023-11-30 06:13:49
Django1.11自带分页器paginator的使用方法
2021-07-04 12:44:23
Python利用PsUtil实现实时监控系统状态
2022-11-26 12:43:11
pycharm 使用心得(一)安装和首次使用
2023-06-14 05:49:37
6个卓越Web设计细节
2010-03-29 12:56:00
php中如何判断一个网页请求是ajax请求还是普通请求
2023-10-13 14:42:30
python+selenium实现京东自动登录及秒杀功能
2021-02-08 13:31:41
MYSQL教程:my.cnf缓存优化
2009-07-30 08:58:00
redis不能访问本机真实ip地址的解决方案
2023-07-05 13:09:44