4 ms·
Be careful with __del__ also in the context of multithreading. __del__ can be called in any thread, where ever the GC currently executes. Some resources however
by albertzeyer 8y ago
Be careful with __del__ also in the context of multithreading. __del__ can be called in any thread, where ever the GC currently executes. Some resources however can only be accessed (and also be cleaned up) from a specific thread (some GUI APIs e.g. only from the main thread, or some other things only from the same thread where they were created).
See e.g. also this bug: https://github.com/tensorflow/tensorflow/issues/22770 https://github.com/tensorflow/tensorflow/issues/22770
Which is still not really resolved. Maybe this is actually some of the problems with circular refs, and then Swig is also involved, and also multi-threading.