Commit c1d0a4aa authored by Julien Muchembled's avatar Julien Muchembled

Also do garbage collection to remove references from non-persistent objects

_objects member BaseTemplateItem class is a PersistentMapping object, which
contains a _dict_ of persistent objects. In some cases, this dict remained in
memory, preventing pickle cache to remove objects with temporary classes.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32811 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f27f1947
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
############################################################################## ##############################################################################
import fnmatch, imp, os, re, shutil, sys import fnmatch, gc, imp, os, re, shutil, sys
from Shared.DC.ZRDB.Connection import Connection as RDBConnection from Shared.DC.ZRDB.Connection import Connection as RDBConnection
from Products.ERP5Type.DiffUtils import DiffFile from Products.ERP5Type.DiffUtils import DiffFile
from Products.ERP5Type.Globals import Persistent, PersistentMapping from Products.ERP5Type.Globals import Persistent, PersistentMapping
...@@ -5603,7 +5603,8 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5603,7 +5603,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
# Doing a savepoint will pickle them to a temporary storage so that all # Doing a savepoint will pickle them to a temporary storage so that all
# references to it can be freed. # references to it can be freed.
transaction.savepoint(optimistic=True) transaction.savepoint(optimistic=True)
self.getPortalObject()._p_jar.cacheMinimize() self._p_jar.cacheMinimize()
gc.collect()
# Remove temporary modules created above to allow import of real modules # Remove temporary modules created above to allow import of real modules
# (during the installation). # (during the installation).
......
...@@ -46,6 +46,7 @@ from Products.ERP5Type.tests.utils import LogInterceptor ...@@ -46,6 +46,7 @@ from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.Workflow import addWorkflowByType from Products.ERP5Type.Workflow import addWorkflowByType
import shutil import shutil
import os import os
import gc
from MethodObject import Method from MethodObject import Method
from Persistence import Persistent from Persistence import Persistent
...@@ -5959,12 +5960,14 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -5959,12 +5960,14 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
bt_path = os.path.join(os.path.dirname(__file__), 'test_data', bt_path = os.path.join(os.path.dirname(__file__), 'test_data',
self._testMethodName) self._testMethodName)
for i in xrange(6): for i in xrange(6):
gc.disable()
bt = template_tool.download(bt_path) bt = template_tool.download(bt_path)
assert object_id_list.pop() == 'some_file' and not object_id_list assert object_id_list.pop() == 'some_file' and not object_id_list
if i in (2, 4, 5): if i in (2, 4, 5):
transaction.commit() transaction.commit()
self.tic() self.tic()
bt.install(force=1) bt.install(force=1)
gc.enable()
assert not object_id_list assert not object_id_list
transaction.commit() transaction.commit()
self.tic() self.tic()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment