I have a program that depends on being able to query a online database. If the internet connection fails, I want the program to continue, but with different parameters. I am currently using an exception like the following:
Code:
try:
(query_status, query_info) = CDDB.query(disc_id)
results = cd_info(query_status, query_info, disc_id)
except:
do something here
this above method works, but unsatisfactory. The problem is I need to wait for over a minute, maybe two for it ito time out.
Is there a method I could use, to place my two lines of code, like an exception. The result would be if the commands did not finish executing in a set amount of time(say 20 seconds). a secondary clause would execute.
for example:
Code:
try:
(query_status, query_info) = CDDB.query(disc_id)
results = cd_info(query_status, query_info, disc_id)
if not finished in 20 seconds:
execute this clause