[Twisted-Python] callFromThread with return

Egor Cheshkov egor at iplus.ru
Wed Sep 17 12:34:41 EDT 2003


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?

Egor.









More information about the Twisted-Python mailing list