On 2023-03-28, Travis Griggs <travisgri...@gmail.com> wrote:
> A while ago I chose to use a deque that is shared between two threads. I did 
> so because the docs say:
>
> "Deques support thread-safe, memory efficient appends and pops from
> either side of the deque with approximately the same O(1)
> performance in either direction.”
>
> (https://docs.python.org/3.11/library/collections.html?highlight=deque#collections.deque)
>
> Earlier today, looking through some server logs I noticed that from
> time to I’m getting a
>
> RuntimeError: deque mutated during iteration
>
> I guess this surprised me. When I see “thread safe”, I don’t expect
> to get errors.

Well, I guess it doesn't say that iteration of a deque is thread
safe. It only claims that appends and pops from either end are thread
safe. It doesn't even claim that inserts, removes, clear, copy, or any
other operations are thread-safe.

--
Grant




-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to