Message6805
Docs say:
Jython implements dict and set by using Java’s ConcurrentHashMap. This means you can just use these standard Python types, and still get high performance concurrency. (They are also atomic like in CPython, as we will describe.)
However, I'm looking at the source code in 2.5.2 in PySet.java and BaseSet.java, and it doesn't use ConcurrentHashMap. Perhaps it ought to. In fact there's a race condition in pop(), where many threads can all pop the same object from the set. Set uses an iterator to get the first object, then removes the object. In between those two operations is a critical section not protected by a lock.
While testing PyMongo 2.2 (which I'm developing -- it'll be released shortly) I saw this race condition causing bugs in tests with about 40 threads all popping from the set concurrently. Many of them got the same object. |
|
Date |
User |
Action |
Args |
2012-03-16 20:16:53 | ajdavis | set | messageid: <1331929013.04.0.00349845243949.issue1854@psf.upfronthosting.co.za> |
2012-03-16 20:16:53 | ajdavis | set | recipients:
+ ajdavis |
2012-03-16 20:16:53 | ajdavis | link | issue1854 messages |
2012-03-16 20:16:52 | ajdavis | create | |
|