This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Adria Garriga
Recipients Adria Garriga
Date 2016-07-08.14:54:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I create several objects in the main thread, and then spawn several threads that "take ownership" of one object each. Within that thread, the objects' attributes' values are not consistent. The bug only happens sometimes.

from threading import Thread
import pdb
n_threads = 8

def f(self):
    self.obj[0] = 0
    t = 0
    while True:
        if t != self.obj[0]:
            pdb.set_trace() # should not happen
        t += 1
        self.obj[0] += 1

for _ in range(n_threads):
    t = Thread(target=lambda: f(t))
    t.obj = [0]

Tested in Python 2.7.11 under Ubuntu 16.04 LTS and OS X. The bug does not happen in Python 3.5 or Python 3.6 .

Attached is a very similar program that exhibits the same issue, but which may be clearer and can sometimes be killed with Ctrl-C.
Date User Action Args
2016-07-08 14:54:31Adria Garrigasetrecipients: + Adria Garriga
2016-07-08 14:54:31Adria Garrigasetmessageid: <>
2016-07-08 14:54:31Adria Garrigalinkissue27468 messages
2016-07-08 14:54:31Adria Garrigacreate