Author: Armin Rigo <[email protected]>
Branch: gc-del
Changeset: r63630:0c9a73e39d8e
Date: 2013-04-26 10:37 +0200
http://bitbucket.org/pypy/pypy/changeset/0c9a73e39d8e/

Log:    Fixes for module/gc.

diff --git a/pypy/interpreter/executioncontext.py 
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -445,16 +445,25 @@
     def __init__(self, space):
         AsyncAction.__init__(self, space)
         self.in_user_del_action = False
+        self.finalizers_lock_count = 0     # for use by the gc module
+        self.enabled_at_app_level = True   # for use by the gc module
 
     def must_be_between_bytecodes(self):
-        if not self.in_user_del_action:
-            from rpython.rlib import rgc
+        if self.finalizers_lock_count == 0:
+            if self.in_user_del_action:
+                # we are between bytecodes and finalizers are not disabled,
+                # proceed.
+                return
+            # finalizers are not disabled but we are not between bytecodes,
+            # call again later
             self.fire()
-            rgc.finalize_later()
+        # then abort the current execution by raising rgc._FinalizeLater
+        from rpython.rlib import rgc
+        rgc.finalize_later()
 
     def perform(self, executioncontext, frame):
         from rpython.rlib import rgc
-        if not self.in_user_del_action:
+        if not self.in_user_del_action and self.finalizers_lock_count == 0:
             self.in_user_del_action = True
             try:
                 rgc.progress_through_finalizer_queue()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to