Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87788 > unrolled thread
| Started by | massi_srb@msn.com |
|---|---|
| First post | 2015-03-20 10:29 -0700 |
| Last post | 2015-03-20 12:19 -0600 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Threading: execute a callback function in the parent thread massi_srb@msn.com - 2015-03-20 10:29 -0700
Re: Threading: execute a callback function in the parent thread Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-20 12:19 -0600
| From | massi_srb@msn.com |
|---|---|
| Date | 2015-03-20 10:29 -0700 |
| Subject | Threading: execute a callback function in the parent thread |
| Message-ID | <b6be91a9-8f65-4136-bd03-af7013e0915b@googlegroups.com> |
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. Thanks in advance.
[toc] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-03-20 12:19 -0600 |
| Message-ID | <mailman.44.1426875639.10327.python-list@python.org> |
| In reply to | #87788 |
On Fri, Mar 20, 2015 at 11:29 AM, <massi_srb@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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web