python - Combine threads -


i'm making program reads udp socket decodes information steim1 function, want plot information on pyqwt when try upload information graph error (core dumped) appears. searched information on web support, part of graph.

#!/usr/bin/env python import random, sys pyqt4 import qtgui, qtcore import socket import threading import queue datetime import datetime, date, time import milibreria pyqt4.qwt5 import *  host = '0.0.0.0' port = 32004 buffer = 1024 my_queue = queue.queue()#################################################### my_queue1= queue.queue()  class readfromudpsocket(threading.thread):      def __init__(self, my_queue):          threading.thread.__init__(self)         self.setdaemon(true)         self.my_queue = my_queue      def run(self):         while true:             buffer1,addr = socketudp.recvfrom(buffer)             self.my_queue.put(buffer1)             print 'udp received'  class process(threading.thread):      def __init__(self, my_queue,my_queue1):         threading.thread.__init__(self)         self.setdaemon(true)         self.my_queue = my_queue         self.my_queue1 = my_queue1         self.alive = threading.event()         self.alive.set()      def run(self):         while true:             buffer3 = self.my_queue.get()             le=len(buffer3)             #today = datetime.now()             #timestamp = today.strftime("%a, %b %d, %y %h:%m:%s")             #print 'dato recibido el:', timestamp             dtj,le=milibreria.steim1(buffer3)             self.my_queue1.put(dtj)  class plot(threading.thread):      def __init__(self, my_queue1):         threading.thread.__init__(self)         self.setdaemon(true)         self.my_queue1 = my_queue1         self.alive = threading.event()         self.alive.set()      def run(self):         while true:             datos = self.my_queue1.get()             print datos,len(datos)             milibreria.plotmat(datos)  if __name__ == '__main__':     # create socket (ipv4 protocol, datagram (udp)) , bind address     socketudp = socket.socket(socket.af_inet, socket.sock_dgram)     socketudp.bind((host, port))     # instantiate & start threads     myserver   = readfromudpsocket(my_queue)     #myserial  = readfromserial(my_queue)     mydisplay  = process(my_queue,my_queue1)     myplot = plot(my_queue1)     myserver.start()     mydisplay.start()     #myserial.start()     myplot.start()     #plotthread = threading.thread(target=main)     #plotthread.start()  while 1:     pass  udpsock.close() 

your application crashing because plotting thread. cannot interact pyqt gui within thread. interaction gui (this includes pyqwt) must done in main thread only.

refactoring code remove plotting thread beyond scope of stack overflow answer. however, if run specific problem when removing plotting thread, posting new question (with details on problem) on stack overflow encouraged.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -