Commits

Armin Rigo committed b48d17b

when not translated, be careful about multiple spaces for
the tests: we must not keep calling rgc.finalize_later() for
an old object belonging to an old space, when a new space
is ready and between bytecodes.

Comments (0)

Files changed (2)

pypy/interpreter/baseobjspace.py

 
     def _invoke_finalizer(self):
         # The call-back from rgc.register_finalizer(), cannot be overridden
-        if not we_are_translated() and hasattr(self, 'space'):
-            # haaaaaack in case this object is from an older test, to
-            # prevent it from blocking the future calls of finalizers...
-            from rpython.rlib import rgc
-            for x, y in rgc._finalizer_queue:
-                if getattr(x, 'space', None) not in (self.space, None):
-                    print '-+- skipping finalizer for %r:' % (self,)
-                    print '    self.space = %r' % (id(self.space),)
-                    print '    later_obj.space = %r' % (id(x.space),)
-                    return    # there is a pending object with another space
         self.invoke_finalizer()
 
     def invoke_finalizer(self):

pypy/interpreter/executioncontext.py

 from pypy.interpreter.error import OperationError
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rlib import jit
+from rpython.rlib.objectmodel import we_are_translated
 
 TICK_COUNTER_STEP = 100
 
     or less anywhere in the middle of code that might not be happy with
     random app-level code mutating data structures under its feet.
     """
+    _current_space_between_bytecodes = None
 
     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
+        self.fire()
 
     def must_be_between_bytecodes(self):
+        if not we_are_translated():
+            # when not translated, be careful about multiple spaces for
+            # the tests: we must not keep calling rgc.finalize_later() for
+            # an old object belonging to an old space, when a new space
+            # is ready and between bytecodes.
+            if UserDelAction._current_space_between_bytecodes is not None:
+                space = self.space
+                if UserDelAction._current_space_between_bytecodes is not space:
+                    return
+
         if self.finalizers_lock_count == 0:
             if self.in_user_del_action:
                 # we are between bytecodes and finalizers are not disabled,
         if not self.in_user_del_action and self.finalizers_lock_count == 0:
             self.in_user_del_action = True
             try:
+                space = executioncontext.space
+                if not we_are_translated():
+                    UserDelAction._current_space_between_bytecodes = space
                 rgc.progress_through_finalizer_queue()
+                if not we_are_translated():
+                    UserDelAction._current_space_between_bytecodes = None
             finally:
                 self.in_user_del_action = False
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.