title: How do I store and access values from a deque where deque is being modified by another thread?
body: <p>My program has two threads - first one for receiving data in form of list of dictionaries and 2nd thread for storing the values in a database.</p>
  
  <pre><code>buffer = collections.deque(maxlen=10)
  
  def process_ticks(bufferarg):
     while True:
         for i in bufferarg:
              #code to insert data in a database
  
  #this tread receives the data and dumps it into a deque with a specified length (so it can function as a circular buffer)
  t1 = threading.Thread(target=socket.connect)
  
  #this threads accesses the deque and processes the data
  t2 = threading.Thread(target=process_ticks(buffer))
  
  t1.start()
  t2.start()
  </code></pre>
  
  <p>However, when I run the code, I get the "deque is being mutated" error.
  Also, how can I make sure that thread runs infinitely, but <code>process_ticks</code> doesn't insert same data from deque twice?</p>