[Tutor] breaking out of a function that takes too long

Serdar Tumgoren zstumgoren at gmail.com
Tue Sep 15 23:02:09 CEST 2009

Hey everyone,
Is there a way to break out of a function if it exceeds a certain time
limit for execution?

There's a Website I'm scraping on a regular basis, and for some reason
that I can't divine the site has radically varying response times. In
some cases, I get a result vary quickly; at other times, my entire
program hangs because of this one call to an external source. Even
more strange, if I quit the scrape when it appears to hang and then
try it again a few moments later, it will sometimes work just fine
("sometimes" being the key word). I'm not certain, but I'm guessing
this inconsistent behavior has something to do with the site that I'm

So again, is there a way to place a time limit on the execution of a
function, after which you can break out of it and then retry it or
move along with the rest of your program?


More information about the Tutor mailing list