6 Nov 2009 6 Nov '09
On Fri, 6 Nov 2009 10:52:54 am Yuvgoog Greenle wrote:
On Fri, Nov 6, 2009 at 1:17 AM, James Y Knight firstname.lastname@example.org wrote:
Is this thread over yet?
Sorry, I just had to point out that pop/add has a side effect that would be apparent on a set that multiple threads access - it loses an item and then gets it back. Sounds like a sleeper race condition that's going to be rare but extremely hard to find if it does occur. Crooked as a gil.
Surely Raymond's suggestion also suffers from a similar race condition?
for x in set: return x
creates a set_iterator. If another thread modifies the original set after the set_iterator is created but before the return, you would get a mysterious and almost impossible to debug RuntimeError.
-- Steven D'Aprano