Python RuntimeError: thread. _ init _ () not called Solution

Source: Internet
Author: User

Python RuntimeError: thread. _ init _ () not called Solution

This article mainly introduces the Python RuntimeError: thread. _ init _ () not called solution. For more information, see

An error is reported when writing a multi-threaded class.

RuntimeError: thread. _ init _ () not called

The Code is as follows:

Class policytread (threading. Thread ):

Def _ init _ (self, params ):

Threading. Thread. _ init _ (self) # here ......

Self. params = params

Def run (self ):

Print "start running y ............"

Time. sleep (10)

Print policy_tran (self. params)

Print "end running y .............."

In init, You need to initialize the Thread first, and then assign values to the parameter to solve the problem.

That is, it cannot be missing

Threading. Thread. _ init _ (self)

This is a usage Note.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.