Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87791
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.018 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'explicitly': 0.05; 'welcome.': 0.07; 'callback': 0.09; 'executed': 0.09; 'api': 0.11; 'thread': 0.14; '(either': 0.16; '(it': 0.16; 'executed.': 0.16; 'executor': 0.16; 'thread,': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'everyone,': 0.19; 'mechanism': 0.19; 'python?': 0.22; 'frameworks': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'slot': 0.31; 'workaround': 0.31; 'allows': 0.31; 'another': 0.32; 'says': 0.33; 'running': 0.33; 'call.': 0.33; 'checking': 0.33; 'fri,': 0.33; 'subject:the': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'executing': 0.36; 'method': 0.36; 'similar': 0.36; 'should': 0.36; 'searching': 0.37; 'being': 0.38; 'to:addr:python- list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'signal': 0.60; 'tell': 0.60; 'provide': 0.64; 'mar': 0.68; '20,': 0.68; '2015': 0.84; 'interrupt': 0.84; 'scheduling': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=VED95fB23O3bQowS81UknS2L8uIyhv32vk/U5Qo1h0U=; b=AEDDvxgo6cJEf5ZvszFwDnuoo/lvOGNaCouIHQFKCsq94XZF8yKa9FROQIF0GM7uN+ tnPxDXe6VWYEJepmUTrPcw6hbPx3H4EXsTGfR8fC1gluJzGCnTzmJWo/tbdrvTSMyHI0 ur0kbVpaLQTHkI/96WR1xeGHi8h4/cXI9iNbTvtvEVbxfQ4uJGLZU6TmVLut5f6DCPDq cG8uLVN+IKEnglOPhkGIQrJp8as+Z00NWztH7pvxhCdOON0leVI2QHPuVRqKKopFQcx0 dd5jiGM/eHxePUCzpUq1emotXTZkmzu7xMokVYaGGchl+/7JxfKM7h3YBPdKvSEyQUZK O2vQ== |
| X-Received | by 10.70.44.100 with SMTP id d4mr189975122pdm.36.1426875636281; Fri, 20 Mar 2015 11:20:36 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <b6be91a9-8f65-4136-bd03-af7013e0915b@googlegroups.com> |
| References | <b6be91a9-8f65-4136-bd03-af7013e0915b@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 20 Mar 2015 12:19:55 -0600 |
| Subject | Re: Threading: execute a callback function in the parent thread |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.44.1426875639.10327.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426875639 news.xs4all.nl 2833 [2001:888:2000:d::a6]:59859 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87791 |
Show key headers only | View raw
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
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
csiph-web