A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-November/093848.html below:

[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it

[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it [Python-Dev] Retrieve an arbitrary element from a setwithoutremoving itSteven D'Aprano steve at pearwood.info
Fri Nov 6 07:01:01 CET 2009
On Fri, 6 Nov 2009 10:52:54 am Yuvgoog Greenle wrote:
> On Fri, Nov 6, 2009 at 1:17 AM, James Y Knight <foom at fuhm.net> 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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4