atomic increment

Fredrik Lundh fredrik at pythonware.com
Wed Aug 27 05:56:47 EDT 2008


Frank Millman wrote:

> Just out of interest, would the following, without a lock, be safe?
> 
> old, atomic_int = atomic_int, atomic_int+1

nope.

there's some information here (make sure you read the comments):

http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-are-thread-safe.htm

and some additional discussion here:

http://mail.python.org/pipermail/python-dev/2006-November/thread.html#69981

</F>




More information about the Python-list mailing list