Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r54930:a189a9081dd3
Date: 2012-05-07 12:44 +0200
http://bitbucket.org/pypy/pypy/changeset/a189a9081dd3/

Log:    A failing test: thread._local() objects are immortal as soon as they
        are accessed by more than one thread, and the threads in question
        stay around.

diff --git a/pypy/module/thread/test/test_local.py 
b/pypy/module/thread/test/test_local.py
--- a/pypy/module/thread/test/test_local.py
+++ b/pypy/module/thread/test/test_local.py
@@ -87,3 +87,23 @@
             thread.start_new_thread(f, (i,))
         self.waitfor(lambda: len(done) == 5, delay=2)
         assert len(done) == 5
+
+    def test_local_is_not_immortal(self):
+        import thread, gc, time
+        class Local(thread._local):
+            def __del__(self):
+                done.append('del')
+        done = []
+        def f():
+            assert not hasattr(l, 'foo')
+            l.bar = 42
+            done.append('ok')
+            self.waitfor(lambda: len(done) == 3, delay=8)
+        l = Local()
+        l.foo = 42
+        thread.start_new_thread(f, ())
+        self.waitfor(lambda: len(done) == 1, delay=2)
+        l = None
+        gc.collect()
+        assert done == ['ok', 'del']
+        done.append('shutdown')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to