On Fri, Mar 20, 2015 at 11:29 AM, <massi_...@msn.com> wrote: > Hi everyone, > > just like the title says I'm searching for a mechanism which allows to call a > callback function from a thread, being the callback executed in the parent > thread (it can also be the main thread). I'm basically looking for something > like the CallAfter method of the wx or the signal slot mechanism of the pyqt. > Is there something similar but made only in native python? any workaround is > welcome.
There's no general way to tell another thread to execute something, because that thread is *already* executing something -- you can't just interrupt it and say "here, do this instead". There has to be some mechanism in place for scheduling the thing to be executed. You can do this with the main thread of frameworks like wx because the main thread in that case is running an event loop which enables the callback to be scheduled. If your target thread is not running an event loop or being used as an executor (either of which should provide a specific API for this), then you will need to have that thread explicitly checking a callback queue from time to time to see if there's anything ready for it to call. -- https://mail.python.org/mailman/listinfo/python-list