Every object I know of in Python can take care of its base class initialization by calling:
super(BaseClass, self).__init__()
This doesn’t seem to be the case with a subclass of threading.Thread, since if I try this in SubClass.__init__(), I get:
RuntimeError: thread.__init__() not called
What gives this error? I looked at the source for threading.Thread and it looks like that __init__ method should set Thread.__initialized = True. I see that all examples use the following __init__:
class YourThread(threading.Thread):
def __init__(self, *args):
threading.Thread.__init__(self)
# whatev else
But why?
This works fine:
I think your code’s bug is that you’re passing the base class, rather than the current class, to
super— i.e. you’re callingsuper(threading.Thread, ..., and that’s just wrong. Hard to say since you don’t show your failing code, but that’s what I infer obliquely from the language you’re using!-)