[New-bugs-announce] [issue16572] Bad multi-inheritance support in some libs like threading or multiprocessing
report at bugs.python.org
Wed Nov 28 22:35:08 CET 2012
New submission from Thomas Chiroux:
when using multi-inheritance and super() in __init__(), super() tries to run each constructor once.
For this to work correctly, it is needed to call super() in each constructor, including for Classes directly inherited from object.
The sample below does not execute correctly because threading.Thread constructor does not call super()
(and because Thread inherit from _Verbose, _Verbose should also call super() )
from threading import Thread
self.param1 = 'foo param1'
class Bar(Thread, Foo):
self.another_param1 = "bar another_param1"
print("Running (%s - %s)" % (self.another_param1, self.param1))
if __name__ == '__main__':
threads = 
for i in range(1, 10):
thread = Bar()
for thread in threads:
This sample work by simply inverting Thread and Foo :
class Bar(Foo, Thread):
The sample is about threading.Thread, but it's also the same for multiprocessing.Process, and maybe for other modules in stdlib.
attached is a proposed path for threading.Tread in 2.7
I've tested the issue and have the same behavior in 2.7 and in 3.3
components: Library (Lib)
title: Bad multi-inheritance support in some libs like threading or multiprocessing
versions: Python 2.7, Python 3.3
Added file: http://bugs.python.org/file28150/diff_threading.py_2.7.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce