Referencing widgets in non-main threads
Blog post: https://blogs.gnome.org/chergert/2018/03/21/gtask-and-threaded-workers/
PyGObject issue: pygobject#184 (closed)
From what I've read in this blog post, destruction of widgets in non-main thread is not supported and it's not safe to even store a reference to a widget in a thread. Does that mean that it's not safe to pass self._callback
to a widget's worker thread to allow communication via GLib.idle_add(callback, event)
in PyGObject? If so, can this be made safe?
It seems really easy for a reference to a widget to sneak in a thread in Python, since x = obj.function
actually returns a wrapper with a reference to the object, so it can be later called simply with x()
, see pygobject#184 (comment 84469) for how it can lead to a bug.
Edited by Nikita Churaev