On Tue, Sep 15, 2009 at 5:02 PM, Serdar Tumgoren <zstumgo...@gmail.com> wrote: > Hey everyone, > Is there a way to break out of a function if it exceeds a certain time > limit for execution?
In general this is tricky. It usually involves setting up another thread to run or monitor the function, then somehow terminating the thread if it runs too long. In your case, it sounds like a better solution is to set a socket timeout. At the beginning of your program - before attempting any access to the website - put import socket socket.setdefaulttimeout(<timeout in seconds>) This will cause the web site fetch to fail by raising socket.timeout if the fetch blocks for longer than the timeout seconds. Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor