title: Python Selenium Timeout Exception Catch
body: <p>In my threads I use a simple variable either set to '1' or '0' to indicate if it is ready to go again. Trying to debug an issue where sometimes this isn't being reset and I think I might have it.</p>
  
  <p>I didn't want connections timing out into some infinite load time (I believe the default for Selenium is not to have a timeout) so I used:</p>
  
  <pre><code>Driver.set_page_load_timeout(30)
  </code></pre>
  
  <p>And later on in that thread I would check</p>
  
  <pre><code>If condition:
   isrunning = 0
  </code></pre>
  
  <p>I had originally thought that the set_page_load_timeout would just stop it loading after 30 seconds but if I'm understanding this correctly it would actually throw an exception so I'd need to do something like:</p>
  
  <pre><code>try:
    Driver.set_page_load_timeout(30)
  except:
    isrunning = 0
    Driver.Close()
  
  -Do whatever else in function -
  If condition:
    isrunning = 0
    Driver.Close()
  </code></pre>
  
  <p>So if it ran over 30 seconds it would close and set to 0 otherwise it would run on and get checked and set to 0 later.</p>
  
  <p>I appreciate this is a tiny snippet of code but the full thing is pretty long winded and I think that's the important part.</p>
  
  <p>I'd appreciate it if someone could confirm I have the right idea here. I'm all up for doing the testing but it's a problem which occurs once every 8 hours or so making it hard to pick apart but I think this potentially fits.</p>