RuntimeError: Thread.__init__() Not Called (Python)

Today I got a really dumb error from Python.

RuntimeError: thread.init() not called

But luckily it’s really easy to fix!

Below is the code before (with the error):

class SomeThread(Thread):
    def __init__(self, myVar):
        self.sMyVar = str(myVar)
    def run(self):
        self.sMyVar = "bla.." + self.sMyVar

And now for the code that resolved the problem:

class SomeThread(Thread):
    def __init__(self, myVar):
        Thread.__init__(self)
        self.sMyVar = str(myVar)
    def run(self):
        self.sMyVar = "bla.." + self.sMyVar

If you have really bad eye-sight and can’t spot the difference between the 2 code block above 😛
What we do is add the following code in the beginning of the construct – or __init__ in Python:

Thread.__init__(self)

Also be aware that I originally did:

from threading import Thread

Which means I don’t have to instantiate it going forward using `threading.Thread`, instead I can do `Thread` alone.