Use the package manager pip to install the library.
pip install git+https://github.com/tandemdude/shared_cbuff.git
There is no limit to the number of ‘reader’ buffer classes however there can only ever be a single ‘writer’ class. If you try to write to the buffer from a read-only class an exception will be raised and vice-versa.
Using the buffer is fairly straightforward
>>> # Create a buffer object >>> scb_a = SharedCircularBuffer("shared_buffer_a", create=True, length=5) >>> # Link a second buffer object to the same memory block as the first >>> scb_b = SharedCircularBuffer("shared_buffer_a", length=5) >>> # Insert items into the buffer >>> scb_a.push(50) >>> scb_a.push(10) >>> scb_a.push(20) >>> scb_a.push(30) >>> # Extract a single item from the buffer >>> scb_b.popitem() 50 >>> # Extract multiple items from the buffer >>> scb_b.popmany(3) [10, 20, 30]
Note that currently, only integer values can be written to and read from the buffer.