Thanks for your help!
I’ve stopped using the idle event to draw the OpenGL canvas, although this seems to have little to do with the problem with this thread. I’ll try to be a little more specific:
I have two threads running. One is the main Python thread that is drawing my buttons and rendering to the GLCanvas, etc. The other one goes off and reads from a file. It does this by using a cpp file (the OrangeLogFile bit) which has Python bindings. I’ve come up with three different configurations:
Number one:
···
def getChunk(self):
while (self.currentposition < self.filesize):
id,size,self.currentposition,timestamp = OrangeLogFile.get_next_chunk(self.fd,self.currentposition)
timestamp = long(timestamp)
print "Id: %s, Size: %d, Timestamp: %ld, Position: %d" % (self.fourcc(id),size,timestamp,self.currentposition)
OrangeLogFile.close(self.fd)
Like this, the file is read too quickly. I need to slow it down. The file I’m reading from is a log file of timestamped data and I need to read each event with the proper spacing between reads.
Number two:
def getChunk(self):
while (self.currentposition < self.filesize):
wx.MicroSleep(10)
id,size,self.currentposition,timestamp = OrangeLogFile.get_next_chunk(self.fd,self.currentposition)
timestamp = long(timestamp)
print "Id: %s, Size: %d, Timestamp: %ld, Position: %d" % (self.fourcc(id),size,timestamp,self.currentposition)
OrangeLogFile.close(self.fd)
Like this, the reading is too slow. It seems that adding the sleep in there causes the thread to yield for a long time and the scheduler doesn’t get back to it for well over 10 microseconds.
Number three:
In this configuration, I added a usleep(10) to the cpp function that is called (OrangeLogFile.get_next_chunk()). This causes the GUI to hang until the file is finished being read. Must be a bug with the Python bindings and scheduler or something.
What I’m thinking I should do right now is use method number 2 and set sys.setcheckinterval() to something very low. Does this seem right? Are there pitfalls to this approach?
Thanks in advance for your help!
Patrick Jakubowski
Share life as it happens with the new Windows Live. Start sharing!