TclStackFree: incorrect freePtr. Call out of sequence?

Hi,

I have a piece of code that graphs streaming data in a new window. If the
cursor is within the graphing window and the cursor has been moved after the
command has been sent to start graphing data, the graphing window would
crash and the message says that "python.exe has stopped working".
In the CMD window, the following error is displayed:
"TclStackFree: incorrect freePtr. Call out of sequence?
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information."
I've tried changing from python 2.7.7 to 2.7.8 and matplotlib-1.3.1 to
1.4.2. The problem persists in both cases.
Any help or insight would be greatly appreciated.
Thank you.

Python code used pertaining to graphing streaming data:

def start():
  global ekg_data
  global ekg_lock
  ekg_lock = Lock()
  
  ekg_data = Queue()
  
  conn.register_notification(Handle_EKG, Handle_EKG_Notify,
callback=ekg_data_ready)
  conn.GATT_WriteCharValue(handle=Handle_StartSweep, value=StartEKG_Value)
  
  ylim([0,128])
  ion()
  show()
  
  t = Thread(target=ekg_plotter)
  t.daemon = True
  t.start()
  
def ekg_plotter():
  global ekg_data
  global ekg_lock
  graph_data = zeros(2000)
  graph, = plot(graph_data)
  while (True):
    newData = []
    with ekg_lock:
      size_q = ekg_data.get()
      graph_data = np.concatenate((graph_data[(len(size_q)):], size_q))
      ekg_data.empty()
    graph.set_ydata(graph_data)
    pause(.01)

def ekg_data_ready(packet_dictionary):
  global ekg_data
  global ekg_lock
  packet, dictionary = packet_dictionary
  data = dictionary["values"][0]
  dataList = [data[i:i+EKG_DATA_SIZE] for i in range(0, len(data),
EKG_DATA_SIZE)]
  parsedList = [unpack("<b", x)[0] for x in dataList]
  with ekg_lock:
    ekg_data.put(parsedList)

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/TclStackFree-incorrect-freePtr-Call-out-of-sequence-tp44287.html
Sent from the matplotlib - devel mailing list archive at Nabble.com.