Hello there ! i am having a problem with threading. OK, i have this GUI app that i am building with pygtk. there is a process (four actually, just working on getting one right now) that needs to run in the background. there is a button that starts the background function. But, it locks up the gui. it doesn't run in the background, it locks everything up. It still runs though. one of the things this background process is to do is updata a viewable area on the GUI. Now when run from a terminal, when i hit CTRL+C it stops the thread, but doesnt kill the GUI, and the TextView gets updated right then with everything it should have gotten before.
def Serial1(): print 'running serial 1' ser = serial.Serial('/dev/ttyS15', 2400, timeout=None) loopy = 1 i = 1 while loopy < 5: x_Now = strftime('%Y-%m-%d %H:%M:%S') i = i + 1 a = ser.read(1)#read one byte a = ord(a) # change byte to integer if (a < 64 )or (a > 127): continue b = ser.read(1) b = ord(b) if (b < 64 )or (b > 127): continue c = ser.read(1) c = ord(c) if c < 92: continue d = ser.read(1) d = ord(d) if d < 128: continue Sensor_ID = (a & 63) + (b & 63) * 64 + (c & 1) * 4096 Status = (c & 62) / 2 + (d & 63) * 32 c = int(c) d = int(d) x_Now = strftime('%Y-%m-%d %H:%M:%S') f = open('/home/piv/PivData/tmp/Serial/'+str(i), 'w') Input1Data = str(Sensor_ID)+'\t'+str(Status)+'\t--------->\t'+x_Now+'\n' Input1Iter = self.Input1Buffer.get_end_iter() self.Input1Buffer.insert(Input1Iter, Input1Data) f.write(str(Sensor_ID)+'\n'+str(c)+'\n'+str(d)+'\n'+str(Status)+'\n'+x_Now) f.close() thread.start_new(Serial1()) the code may not be best form, i am still fairly new at this. so i am also open to any constructive critisism. thanks shawn _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor