You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class TestClass:
def __init__(self):
log.info('I am here')
def __del__(self):
log.info('I am gone')
@time_trigger('startup')
def startup():
a = TestClass()
task.sleep(3)
del a
"I am gone" is never displayed.
Compare to python:
import time
class TestClass:
def __init__(self):
print('I am here')
def __del__(self):
print('I am gone')
a = TestClass()
time.sleep(3)
del a
The text was updated successfully, but these errors were encountered:
Good catch. Part of the issue is the __del__ method defined in pyscript is async, so the python destructor can't call it. But even with a @pyscript_compile decorator it still doesn't work, which I'm still investigating.
It should work now. The __del__ function requires the @pyscript_compile decorator, since it needs to be a regular function. That means it can't use any pyscript features. To confirm __del__ is called I modified a global list, eg:
called= []
classTestClass:
def__init__(self):
log.info('I am here')
@pyscript_compiledef__del__(self):
called.append("__del__")
Test code:
"I am gone" is never displayed.
Compare to python:
The text was updated successfully, but these errors were encountered: