Skip to content

Instantly share code, notes, and snippets.

@forslund
Created August 24, 2017 12:45
Show Gist options
  • Save forslund/44eccf583091afacb810e7cae08cafad to your computer and use it in GitHub Desktop.
Save forslund/44eccf583091afacb810e7cae08cafad to your computer and use it in GitHub Desktop.
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