Re: [Twisted-Python] Synchronization
Hello Glyph:
Stackless tasklets that "want to run" ought to be running due to events transpiring. One kind of event is "time passes" (reactor.callLater), other types of events are user interaction (like callbacks in a UI such as GTK) or I/O events (dataReceived, connectionLost, et. al.)
There should be no need for native threads in a Twisted+Stackless universe. Even if all your tasklets >constantly want to be doing work, they should be able >to do that via a tasklet scheduler
I am still relatively new to Twisted... In the past, I tried using loopingCall. In turn, the task would make a call to stackless.schedule() that would allow waiting tasklets to execute. The problem was that certain tests would fail resulting in reactor errors or deferreds would not fire. Also I really don't have an understanding of what happens when a callback calls stackless.schedule(). So I would like to avoid this construct if I can. (I posted all the aforementioned in the "Advice on Writing a Custom Reactor." ) As a note, under the two threads approach, I still lost "deferreds." However placing a time.sleep() after calling a deferred method, would result in the deferred properly functioning. I am operating under the suspicion that there is some issue involving the GIL. This is one of the "issues" I mentioned in my previous post. that is always
running with a 0 callLater timeout. Do you think this would be possible?
Glyph, I modified my web server example (in the Twisted/Stackless code examples repository). Now the code is: reactor.listenTCP(port, MyHttpFactory()) reactor.callLater(1, stackless.schedule) reactor.run() Unfortunately the tick tasklet does not pump out numbers until my web browser makes a request.... (Hopefully) I am doing something wrong? Glyph, once again, I apologise for being a newbie. I thought there should be no need for native threads in a Twisted/Stackless universe too. However by adding an additional thread, my application works, the solution is relatively clean, and I have a better understanding of what is happening. Right now, the important thing is that I am reaping the benefits of Twisted/Stackless which allow me to focus on WS-BPEL specific programming. Without Stackless and Twisted, I couldn't do a fraction of what I am currently achieving. Also by posting my problems in the Stackless mailing list, I found out that there are many other people interested in using Stackless with Twisted. Still I will always be on the lookout for the right Twisted way to do things. Cheers, Andrew ____________________________________________________________________________________ Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. http://answers.yahoo.com/dir/?link=list&sid=396546091
participants (1)
-
Andrew Francis