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

2015-04-25 Thread xiaobing jiang
Changes by xiaobing jiang s7v7nisla...@gmail.com: -- nosy: +s7v7nisla...@gmail.com ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15330 ___ ___

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

2012-07-12 Thread Chris Jerdonek
Chris Jerdonek chris.jerdo...@gmail.com 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

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

2012-07-12 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com 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

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

2012-07-11 Thread Chris Jerdonek
New submission from Chris Jerdonek chris.jerdo...@gmail.com: 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

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

2012-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- assignee: - rhettinger priority: normal - low versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15330 ___

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

2012-07-11 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: By thread-safe you mean that the operation should be atomic? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15330 ___

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

2012-07-11 Thread Chris Jerdonek
Chris Jerdonek chris.jerdo...@gmail.com 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). -- ___

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

2012-07-11 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com 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