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
If you need to make objects that free/stop/cleanup resources when no longer used, the best way to do it is with a context manager. This will ensure that things are cleaned up, even if an exception occurs. The second best way is to make a close() method and ensure that close() is called when the object is no longer needed.
Or decorated with a warning ?
If you need to make objects that free/stop/cleanup resources when no longer used, the best way to do it is with a context manager. This will ensure that things are cleaned up, even if an exception occurs. The second best way is to make a
close()
method and ensure thatclose()
is called when the object is no longer needed.__del__
is non-deterministic by definition, so is not really the right tool for that job. See https://github.com/orgs/micropython/discussions/14287 as an example of how__del__
can be problematic in this way.Originally posted by @dlech in micropython/micropython#1878 (comment)
The text was updated successfully, but these errors were encountered: