>DansTonCode();

Citation de code source en Python257

 23 May 2016 à 01:30
        except tweepy.TweepError as e:
            print e
            if e.reason == 'Not authorized':
                return []
            try:
                wait_secs = 10.0
                time.sleep(wait_secs)
                rate_status = api.rate_limit_status()
                print "Error! Remaining hits : ", rate_status['remaining_hits']
                if rate_status['remaining_hits'] == 0:
                    print "No remaining hits..."
                    api = get_best_context()
                    print "New context selected"
                    rate_status = api.rate_limit_status()
                while rate_status['remaining_hits'] == 0:
                    wait_until = rate_status['reset_time_in_seconds']
                    wait_secs = wait_until - time.time() + 30.0
                    print time.strftime("%d %b: %H:%M:%S ", time.localtime())
                    print "waiting %f minutes..." % float(wait_secs / 60.0)
                    time.sleep(wait_secs)
                    rate_status = api.rate_limit_status()
            except tweepy.TweepError as e:
                wait_secs = 600.0
                print "Waiting %f seconds(Something is wrong)..." % wait_secs
                time.sleep(wait_secs)

Allez voir les citations similaires

Partagez cette citation