This repository has been archived by the owner on Aug 20, 2018. It is now read-only.
Bug 761564 - Memory leaks in Mozmill Python code which keeps references around and never completely releases the Mozmill object. r=jhammel #99
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
35d710d
Bug 761564 - Memory leaks in Mozmill Python code which keeps referenc…
whimboo 7c80289
Revert type of event_handlers back to a list
whimboo 00cdbc1
Remove unnecessary __del__ method for LoggerListener
whimboo 30fe735
Fix merge conflicts
whimboo a5fb91f
Fix merge conflicts
whimboo 8d1061a
Handlers have to be passed in as a list
whimboo 73c2a1f
Remove weakref dependency and update tests to not output to console
whimboo 1510b5b
Address review comments
whimboo 8865f62
Merge branch 'master' of github.com:mozilla/mozmill into bug761564_we…
whimboo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from cStringIO import StringIO | ||
import os | ||
import sys | ||
import tempfile | ||
import unittest | ||
|
||
import mozmill | ||
from mozmill.logger import LoggerListener | ||
|
||
|
||
class ModuleTest(unittest.TestCase): | ||
def make_test(self): | ||
"""make an example test to run""" | ||
test = """var test_something = function() {}""" | ||
fd, path = tempfile.mkstemp() | ||
os.write(fd, test) | ||
os.close(fd) | ||
|
||
return path | ||
|
||
def do_test(self, relative_test_path): | ||
testpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
relative_test_path) | ||
tests = [{'path': testpath}] | ||
|
||
info_data= StringIO() | ||
logger = LoggerListener(console_level="DEBUG", console_stream=info_data) | ||
|
||
m = mozmill.MozMill.create(handlers=[logger]) | ||
m.run(tests) | ||
results = m.finish() | ||
|
||
self.assertEqual(sys.getrefcount(logger), 2, | ||
"Only a single reference to the logger exists") | ||
self.assertEqual(sys.getrefcount(m), 2, | ||
"Only a single reference to mozmill exists") | ||
|
||
return results | ||
|
||
def test_modules(self): | ||
results = self.do_test(self.make_test()) | ||
|
||
self.assertEqual(sys.getrefcount(results), 2, | ||
"Only a single reference to results exists") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may want to also call close in addition to setting these to None, just to be very certain that the close() command is called on the asnycCore Telnet object (what the Bridge inherits from). So, i.e.:
if self.back_channel:
self.back_channel.close()
self.bridge.close()
self.back_channel = None
self.bridge = None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about this too and was thinking it's not absolutely necessary. But sure, I will add it back so that we are on the safe side.