Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PythonAlgorithm::__del__ method is not called #10356

Closed
martyngigg opened this issue May 21, 2014 · 1 comment
Closed

PythonAlgorithm::__del__ method is not called #10356

martyngigg opened this issue May 21, 2014 · 1 comment
Assignees
Labels
High Priority An issue or pull request that if not addressed is severe enough to postponse a release. Maintenance Unassigned issues to be addressed in the next maintenance period.
Milestone

Comments

@martyngigg
Copy link
Member

This scripts demonstrates that the Python object __del__ method is never called when it should be, indicating that the objects are not being deleted.

#!python
from mantid.kernel import *
from mantid.api import *

OBJECT_COUNT = 0

class ObjectTracker(Algorithm):

    def __init__(self):
        global OBJECT_COUNT
        OBJECT_COUNT += 1
        Algorithm.__init__(self)

    def __del__(self):
        global OBJECT_COUNT
        OBJECT_COUNT -= 1
        print "Called __del__"

    def PyInit(self):
        pass

    def PyExec(self):
        print "PyExec"

####################################################################                                                                          
AlgorithmFactory.subscribe(ObjectTracker)
####################################################################                                                                          

OBJECT_COUNT = 0
for i in range(10):
    alg = AlgorithmManager.createUnmanaged("ObjectTracker")
    print "Global object count=%d" % OBJECT_COUNT
    alg.initialize()
    alg.setLogging(False)
    alg.execute()
    del alg

print "Final count",OBJECT_COUNT

The final count should be zero but it will be 10.


Keywords: Maintenance

@martyngigg
Copy link
Member Author

This issue was originally trac ticket 9513

@martyngigg martyngigg added High Priority An issue or pull request that if not addressed is severe enough to postponse a release. Python Maintenance Unassigned issues to be addressed in the next maintenance period. labels Jun 3, 2015
@martyngigg martyngigg self-assigned this Jun 3, 2015
@martyngigg martyngigg added this to the Release 3.3 milestone Jun 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority An issue or pull request that if not addressed is severe enough to postponse a release. Maintenance Unassigned issues to be addressed in the next maintenance period.
Projects
None yet
Development

No branches or pull requests

1 participant