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 ? Thank you. Quoting Nitro <[email protected]>: > Am 28.05.2010, 20:34 Uhr, schrieb <[email protected]>: > >> hi, >> >> Callbacks serialization is clear to me. >> >> I'll try to rephrase the question: two requests are incoming for >> reactor() >> to handle. Each request has its own chain of callbacks. >> At some point one of the requests need to update the same >> global data structure, and another request need to delete from the same >> global data structure. >> So theoretically, correct me if I wrong, will be a data collision. >> If it is, than how can I prevent it? Example please. > > It will go like this: > > reactor loop: > > 1) receive Event A > - fire deferred callback > - deferred callback does data[key] = value > 2) receive Event B > - fire deferred callback > - del data[key] > > So one event is processed after another. Determining if it's a data > collision is up to you. E.g. you could use something like a revision > number. Each time you change the dictionary, increase it by one. Then if > you try to change the dictionary and the client gave a different revision > id then the last one, you know there is a collision. > What you do sounds very much like database transactions. Those are not > easy to do. One example is the ZODB which can do what you want. For > example via BTrees. But I guess there are more lightweight systems which > do what you want, too. It all depends where you want to go with your app. > That's up to you though and not really a question in regards to twisted or > networking. > > -Matthias > > _______________________________________________ > Twisted-Python mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > _______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
