[Twisted-Python] Shared resource manioulation example

Allen Short washort at twistedmatrix.com
Fri May 28 10:11:48 MDT 2010


On Fri, May 28, 2010 at 8:46 AM,  <vitaly at synapticvision.com> wrote:
> I'm looking for a Twisted based example how
> it should be properly done update/delete of global dictionary's
> SAME key:value pair from different functions all together.
> Or by another words, two functions are trying to update the same
> key:value pair of the same dictionary at the same time, than how to do
> it properly with Twisted?

Twisted doesn't change anything about Python in this regard. One
update to the dictionary is going to happen before the other. If these
updates are being done from different threads, you need some kind of
synchronization to make them happen in the order you want.

However, if you aren't explicitly using threads in your code, remember
that Twisted doesn't run your code outside the main thread unless you
ask it to. So nothing happens at "the same time" -- one function runs,
then the other.

What problems are you running into?




More information about the Twisted-Python mailing list