Author: Armin Rigo <ar...@tunes.org>
Branch: stmgc-c8-gcc
Changeset: r79361:81b0687acb77
Date: 2015-09-01 18:11 +0200
http://bitbucket.org/pypy/pypy/changeset/81b0687acb77/

Log:    threadlocalproperty: add the clear() method, to clear the value in
        all threads. Bit of a hack.

diff --git a/lib_pypy/transaction.py b/lib_pypy/transaction.py
--- a/lib_pypy/transaction.py
+++ b/lib_pypy/transaction.py
@@ -239,12 +239,21 @@
     def __init__(self, default_factory=None):
         self.tl_default_factory = default_factory
         self.tl_local = thread._local()
+        self.tl_all_threads = []
+
+    def clear(self, obj):
+        for wrefs in self.tl_all_threads:
+            try:
+                del wrefs[obj]
+            except KeyError:
+                pass
 
     def tl_wrefs(self):
         try:
             return self.tl_local.wrefs
         except AttributeError:
             self.tl_local.wrefs = wrefs = weakkeyiddict()
+            self.tl_all_threads.append(wrefs)
             return wrefs
 
     def __get__(self, obj, cls=None):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to