Q:

Does mechanize have an option to retry a request if it fails?

Is there a way to set mechanize to retry an HTTP request if it fails due to timeout? Or do I need to put it in an infinite loop and make it break out of it when the request was successful?

A:

You need to test the timeout exception yourself. The following untested code shows the idea:
import mechanize
import socket
timeout_occurred = False
br = mechanize.Browser()
try:
    br.open("http://python.org/", timeout=0.001)
except mechanize.URLError as exc:
    if isinstance(exc.reason, socket.timeout):
        timeout_occurred = True
if timeout_occurred:
    # retry
    br.open("http://python.org/", timeout=0.001)

Also you need to read the faq about how timeout works. 

