On Fri, May 28, 2010 at 12:10 PM, <[email protected]> wrote: > > Of course its up to me to determine if it's a data collision or not, > but I was thinking may be Twisted can provide me with some already > existing mechanism of its own. After all its already a pretty massive > and complicated framework with tons of capabilities ... > > But I'd like to get back to the point of the question: if at some > point EventA callbacks and EventB callbacks need to work on the same > global variable, than what would be a Twisted way (if exist) to > prevent data collision ?
In the way that you have described it, that's a question for your code. In the general case, you don't know what order callbacks on two chains will be called in. The advantage of async is that you can use a standard Python type as a mutex, and relinquish control if it's not ready. Set a variable when one chain is working, and if another chain encounters that, have it try later by creating and retuning a new Deferred with its work on that callback, or with reactor.callLater(). _______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
