Created
August 24, 2017 12:45
-
-
Save forslund/44eccf583091afacb810e7cae08cafad to your computer and use it in GitHub Desktop.
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
from mycroft.skills.core import MycroftSkill | |
from mycroft.messagebus.client.ws import WebsocketClient | |
import sys | |
import gc | |
class TestSkill(MycroftSkill): | |
def __init__(self): | |
super(TestSkill, self).__init__() | |
self._dir = './' | |
def __del__(self): | |
print '==== Deleting {} ===='.format(self.name) | |
# Works | |
s = TestSkill() | |
s = None | |
gc.collect() #enforce garbage collection to make sure we see the message | |
# Does not work | |
ws = WebsocketClient() | |
s = TestSkill() | |
print 'Refcount before bind: {}'.format(sys.getrefcount(s)) | |
s.bind(ws) | |
print 'Refcount after bind: {}'.format(sys.getrefcount(s)) | |
s.shutdown() | |
print 'Refcount after shutdown: {}'.format(sys.getrefcount(s)) | |
s = None | |
gc.collect() #enforce garbage collection to make sure we see the message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment