[Zope] Asynchronous dtml?

ender kthangavelu@earthlink.net
Sat, 30 Jun 2001 16:44:53 -0700


On Tuesday 12 June 2001 13:17, Dieter Maurer wrote:
>>Paul Zwarts writes:
>> > If you have time consuming dtml in a method, is it possible to call the
>> > DTML method and allow it to run by itself (in paralell), where its
>> > completion being independant from the page being written to the client?
>>
>>This will not be easy:
>>
>>  what should your DTML do?
>>
>>    1. build the response to the request?
>>       In this case, you would need to wait for the method
>>       finishing before the request is completed
>>
>>    2. change the data?
>>
>>       in this case, you need a ZODB connection.
>>       These connections are the limiting factor for
>>       the number of Zope threads.
>>       As I understand, there are up to seven connections.
>>
>>In principle, you can spawn a new thread for asnychronous
>>DTML execution. But you must be very careful, as you
>>may leave the relatively safe Zope execution context
>>(automatic transaction management, replicated data per
>>thread, conflict resolution).

its possible to write async dtml method without spawning a new thread by 
integrating with asyncore. although its tricky you can still get transaction 
integrity by having by having a before async call transaction and another 
transaction when the method returns (it will probably get serviced by another 
thread).

except for some really extreme cases this is not nesc and normally the 
problem is better solved by other means.

one case that does come to mind, is when you have potentially long external 
interaction with foriegn servers.

if anyone's interested in some sample code, feel free to email me.

cheers

kapil