写多线程脚本,运行的时候报错

File "/usr/local/lib/python2.6/threading.py", line 465, in start
    raise RuntimeError("thread.__init__() not called")
RuntimeError: thread.__init__() not called

原因是线程类中构造函数__init__()中未调用父类的初始化方法,在__init__()函数里加入调用父类初始化方法的代码就OK了,

类似下边这样【特殊字体代码为新添加的】

class MyThread(threading.Thread):
    def __init__(self,ip_port_seg):
        threading.Thread.__init__(self)
        self.ip_port_seg = ip_port_seg

相关文章:

  • 2021-06-09
  • 2022-12-23
  • 2021-09-11
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
猜你喜欢
  • 2021-04-09
  • 2022-12-23
  • 2021-04-05
  • 2021-10-22
  • 2022-01-23
  • 2021-05-04
  • 2022-01-03
相关资源
相似解决方案