I'd gotten the impression that python's threading module was a very frightening thing, and had put off getting to know it. That's too bad, because when I finally looked at it, it provided a very simple way to add timeouts to some of my code. And - unlike os.fork(), etc. - it works on Windows!
t = threading.Thread(target=self.code) t.start() t.join(self.timeout) if t.isAlive(): completed = False self.msg = 'Timed out after %s seconds' % (self.timeout) if self.killOnTimeout: t._Thread__stop()