Message180269
> I thought that access to the value field of Value instances was
> protected by locks to avoid lost updates.
Loads and stores are both atomic. But "+=" is made up of two operations, a load followed by a store, and the lock is dropped between the two.
The same lack of atomicity applies when using "+=" to modify an attribute of a normal python object in a multithreaded program.
If you want an atomic increment you could try
def do_inc(integer):
with integer.get_lock():
integer.value += 1 |
|
Date |
User |
Action |
Args |
2013-01-19 22:18:08 | sbt | set | recipients:
+ sbt, lechten |
2013-01-19 22:18:08 | sbt | set | messageid: <1358633888.74.0.0672288305869.issue16998@psf.upfronthosting.co.za> |
2013-01-19 22:18:08 | sbt | link | issue16998 messages |
2013-01-19 22:18:07 | sbt | create | |
|