I found a possible solution here:
http://mail.python.org/pipermail/pyt...il/001307.html
It uses a code like this to force a timeout:
Code:
import signal
def alarmHandler(*args):
"""
signal handler for SIGALRM, just raise an exception
"""
raise "TimeOut"
....
signal.signal(signal.SIGALRM, alarmHandler)
try:
# set timeout
signal.alarm(120)
#... urllib.urlretrieve pages
except "TimeOut":
# some error handling
signal.alarm(0)
But it seems like the signal module is not present in py60.
I'm trying with e32.Ao_Timer()
Code:
def timeoutHandler():
raise IOError, "Timeout error"
try:
timer = e32.Ao_timer()
timer.after(120,timeoutHandler)
# comms. function here...
timer.cancel()
except:
# capture exception here...
The timer calls timeoutHandler, and the exception is raised (I can see it in the python console), but not captured by the try. Seems like it's launched in a different thread.
is there a solution to raise the exception to the thread from where the timer was triggered?
regards.