def followLink(): try: while True: print 1 url, country = link_queue.get(False, 1) print 2 browser = Browser() print 3 browser.open(url) print 4 browser.getLink('Company Size').click() print 5 browser.getLink('Sector Type').click() print 6, browser.url if not country: for i in range(60): link_queue.put((url + '/%03i' % i, True)) except Queue.Empty: pass