Re: CPython 2.7: Weakset data changing size during internal iteration



On Fri, 01 Jun 2012 08:23:44 -0700, Temia Eszteri wrote:

I've got a bit of a problem - my project uses weak sets in multiple
areas, the problem case in particular being to indicate what objects are
using a particular texture, if any, so that its priority in OpenGL can
be adjusted to match at the same time as it being (de)referenced by any
explicit calls.

Problem is that for certain high-frequency operations, it seems there's
too much data going in and out for it to handle

I doubt that very much. If you are using threads, it is more likely your
code has a race condition where you are modifying a weak set at the same
time another thread is trying to iterate over it (in this case, to
determine it's length), and because it's a race condition, it only
happens when conditions are *just right*. Since race conditions hitting
are usually rare, you only notice it when there's a lot of data.



--
Steven
.



Relevant Pages

  • Re: Thread-safe priority queue?
    ... Looks like a race condition in that... ... def initialize ... def push(obj, pri = obj.queue_priority) ... raise ThreadError, "priority queue empty" ...
    (comp.lang.ruby)
  • Re: Thread-safe priority queue?
    ... Looks like a race condition in that... ... def initialize ... # the result of sending #queue_priority to +obj+. ... raise ThreadError, "priority queue empty" ...
    (comp.lang.ruby)
  • Re: race on multi-processor solaris
    ... >> I ran into a race condition when I tried to run my multi threads ... My main thread had the lowest priority than other ... > it does a condition variable broadcast. ... > and the sort of race you're seeing. ...
    (comp.unix.solaris)
  • Re: Thread-safe priority queue?
    ... Looks like a race condition in that... ... def initialize ... # the result of sending #queue_priority to +obj+. ... raise ThreadError, "priority queue empty" ...
    (comp.lang.ruby)