[Twisted-Python] callFromThread with return

Syver Enstad syver at inout.no
Thu Sep 18 05:46:03 EDT 2003


Egor Cheshkov <egor at iplus.ru> writes:

> Itamar Shtull-Trauring ?????:
> 
> >On Wed, 17 Sep 2003 12:58:29 +0400
> >Egor Cheshkov <egor at iplus.ru> wrote:
> >
> >
> >>Hello! Suppose I run task in worker thread (e.g. database transaction)
> >>
> >> and I need to do some IO (PB call) and get the result from it
> >> during transaction. Since I run not in reactor's thread it's ok to
> >> block and wait for the result. I know that there is callFromThread
> >> but it never return any result. Is it possible to implement
> >> something like callFromThread that can block, wait for result and
> >> return it?
> >>
> >
> >As documented in the threading howto, you can use
> >twisted.internet.threads.deferToThread.
> >
> If I understand right, I should use deferToThread to shedule long
> running task from main thread (that running event loop), i need
> different thing. I need to shedule a method to be run in the main
> event loop from another thread. It is the thing that callFromThread
> does, but callFromThread does not return anything. I need to get
> result from such call. Is it possible?

Can't you pass yourself and have the method that you pass to
callFromThread callback on a method on yourself with the results?

 





More information about the Twisted-Python mailing list