Hi everyone!

Im stuck...

I'm currently writing a GUI program to control a piece of machinery. I am using wxPython along with a few other bits and bobs including USPP for serial access.

My problem is that i need some way of 'pinging' the machine. ie I want to be able to regularly send an 'are you still there' message to the on board hardware, receive a simple yes or no and not really know it has done anything (must not interrupt the usability of the program)

Ive done some searching and i think threads must be the answer here but that is totally new territory for me...

Any help would be greatly appreciated :-)


Mark :mrgreen:

Any hints on how you solved it?


import thread
import time
def RunPing(self):
while 1:
print "PING!"

clearly there will be a little more to it in the end... lol, but that seems to do the trick.

Starts a new thread that repeats an action every 'x' seconds. The rest of the progam can continue as normal. Jobs-a-goodun :-)

One thing to note is that its a good idea to close the thread when the program exits...

def OnClose(self, event):

Not sure how it would work with more than 1 thread but 1 is all i need :-)


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.