is +=1 thread safe

Aahz aahz at pythoncraft.com
Sun May 4 16:19:05 EDT 2008


In article <mailman.554.1209926677.12834.python-list at python.org>,
Gary Herron  <gherron at islandtraining.com> wrote:
>
>However, the upshot of all of this is that one must maintain extreme 
>skepticism.   Unless you know both your Python code and any extension 
>modules you call, and you know them at a level necessary to find such 
>details, you must conclude that any operation, no matter how atomic it 
>my look, may in fact not be atomic. 

Absolutely.  Note that your statement is insufficiently encompassing:
any Python library code might easily use classes that define special
methods that cause GIL release.

This is why those of us who champion correct use of threads say that the
only easy way to create working threaded programs is to pass objects
around in Queues and never never never use an object in multiple threads.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Help a hearing-impaired person: http://rule6.info/hearing.html



More information about the Python-list mailing list