Skip to content

Commit

Permalink
sleeps for x seconds search fails in safe mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tristantao committed Nov 10, 2014
1 parent d147f91 commit 01ed0a6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pybingsearch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import urllib2
import requests
import pdb
import time

class PyBingException(Exception):
pass
Expand Down Expand Up @@ -36,9 +37,11 @@ def _search(self, query, limit, offset, format):
try:
json_results = r.json()
except ValueError as vE:
print "[ERROR] Request returned with code %s, error msg: %s" % (r.status_code, r.text)
if not self.safe:
raise PyBingException("Request returned with code %s, error msg: %s" % (r.status_code, r.text))
else:
print "[ERROR] Request returned with code %s, error msg: %s. \nContinuing in 5 seconds." % (r.status_code, r.text)
time.slee(5)
try:
next_link = json_results['d']['__next']
except KeyError as kE:
Expand Down

0 comments on commit 01ed0a6

Please sign in to comment.