[Stackless] Question about reactor.interleave and callFromThread

Andrew Francis andrewfr_ice at yahoo.com
Sun Jan 21 02:47:14 CET 2007


Hello Colleagues :

I understand that there aren't many people that use
both Stackless and Twisted. However there seems to be
people working on the same thing and we all seem to
have pieces of a solution. I am still unclear about
writing a reactor for Stackless.  I am running on the
assumption that it is best to run Stackless and
Twisted in their own threads (if I could do what I
want in a single thread, that would be great). I am
also operating under the assumption that it good to
have the two threads communicate via queues
(Queue.Queue).

These are some of the issues I don't understand :

1. Whether (and how) one should call a deferred using
callFromThread? For instance
client.getPage()/addCallback. 

1A. What does callFromThread exactly do? Will the
calling thread block?

2. How does reactor.interleave work? Assume that the
main Stackless loop is as follows :

#set stuff up

while (stackless.getruncount() > 1) :
    stackless.schedule()

and my callbacks and request handlers write to a
queue. Example :

postRequest.addCallback(self.__handleResponse__).addErrback(self.__handleError__)
    

def __handleResponse__(self, pageData):
        
        self.queue.put(pageData)
        return

~~~

def processResponse(self, httpServer):
        #try:
            
           """
           get reply
           """
           reply = self.myQueue.get()
                         
httpServer.write(reply.toxml().encode("utf-8"))
                          
           httpServer.finish()
           return
         

What should I do to make the Stackless and Twisted
threads to properly inter-operate? Besides a client
time-out from a slow RequestHandler, that are the
pit-falls of a requestHandler blocking on a reply from
a queue?

Once I have a solution, I would be more than happy to 
summarize on the Stackless wiki. Thanks in advance.

Cheers,
Andrew



 
____________________________________________________________________________________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list