[issue15330] allow deque to act as a thread-safe circular buffer

2015-04-25 Thread xiaobing jiang
Changes by xiaobing jiang : -- nosy: +s7v7nisla...@gmail.com ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: > A couple questions: what does "won't break" mean That means that its internal invariants always survive in a multi-threaded environment. > that it won't throw an exception of a type that it > wouldn't normally throw in a single-threaded environment?

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-11 Thread Chris Jerdonek
Chris Jerdonek added the comment: Thanks for the info. A couple questions: what does "won't break" mean -- that it won't throw an exception of a type that it wouldn't normally throw in a single-threaded environment? And does this mean that not even deque.pop() is atomic? -- __

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: We make almost no guarantees about atomicity. If something in CPython happens to be atomic, it is not guaranteed to hold in other implementations. The recommendation is to use locks anywhere you need a critical section of code. FWIW, the term thread-saf

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-11 Thread Chris Jerdonek
Chris Jerdonek added the comment: Yes, atomic. I was under the impression that the existing deque.rotate() is atomic, in which case deque.rotate(1) almost provides what I'm suggesting (lacking only the return value). -- ___ Python tracker

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: By thread-safe you mean that the operation should be atomic? -- ___ Python tracker ___ ___ Pytho

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger priority: normal -> low versions: +Python 3.4 ___ Python tracker ___ ___ Py

[issue15330] allow deque to act as a thread-safe circular buffer

2012-07-11 Thread Chris Jerdonek
New submission from Chris Jerdonek : It seems like it would be useful if collections.deque had a thread-safe method that could rotate(1) and return the rotated value. This would let deque to act as a thread-safe circular buffer (e.g. if serving jobs to multiple threads in a loop, like `python