[issue11618] Locks broken wrt timeouts on Windows

Kristján Valur Jónsson report at bugs.python.org
Tue Mar 22 10:16:57 CET 2011


Kristján Valur Jónsson <kristjan at ccpgames.com> added the comment:

Martin: I wouldn't worry too much about replacing a "Mutex" with a "Semaphore".  There is no reason to believe that they behave in any way different scheduling wise, and if they did, then any python code that this would affect would be extremely poorly written.

sbt:
Look, I really hate to be a pain but please consider:  In line 50 of your patch the thread may pause at any point, perhaps even a number of times.  Meanwhile, a number of locks/unlocks may go by.  The values of "owned" and "timeouts" that the reader sees may be from any number of different lock states that the lock goes through during this, including any number of different reset cycles of these counters.  In short, there is no guarantee that the values read represent any kind of mutually consistent state.  They might as well be from two different locks.

Please allow me to repeat:  Lockless programming is notoriously hard and there is almost always one subtlety or other that is overlooked.  I can't begin to count the number of times I've reluctantly had to admit defeat to its devious manipulations.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11618>
_______________________________________


More information about the Python-bugs-list mailing list