clearing batch also clears the list in the queue before it's processed.
batch
writer_queue.put((query, table_name, batch.copy()))
Always pass immutable data or copies when sharing between threads to avoid side effects.