[Twisted-Python] callFromThread with return

Andrew Bennetts andrew-twisted at puzzling.org
Mon Oct 6 22:23:18 EDT 2003

On Mon, Oct 06, 2003 at 10:11:42PM +0200, Matthias Urlichs wrote:
> Hi, Andrew Bennetts wrote:
> >          But how does the                          .
> >      Main Thread pass a result                     .
> >        to Worker Thread and                        .
> >        resume its execution?                       ?
> Just put it in a Queue and wait on it in the thread. Standard Python.

It seems cleaner to me for a worker thread to say:
    result = blockingCallFromThread(func, arg1, arg2, ...)

    q = Queue.Queue()
    reactor.callFromThread(func, q, arg1, arg2)
    result = q.get()

Especially seeing as the latter requires cluttering 'func' with details of
how to get the result back (i.e. a call to q.put), when the solution I
proposed in my previous email would make it transparent.


More information about the Twisted-Python mailing list