Exemplo n.º 1
0
    def before_sleep(retry_state):
        exc = retry_state.outcome.exception()

        if isinstance(exc, TwitterPublicAPIRateLimitError):
            loading_bar.inc('tokens')

        else:
            loading_bar.inc('failures')
            loading_bar.print(
                'Failed to call Twitter search. Will retry in %s' %
                prettyprint_seconds(retry_state.idle_for))
Exemplo n.º 2
0
        def before_sleep(retry_state):
            exc = retry_state.outcome.exception()

            if isinstance(exc, CrowdTangleRateLimitExceeded):
                reason = 'Call failed because of rate limit!'

            elif isinstance(exc, CrowdTangleInvalidJSONError):
                reason = 'Call failed because of invalid JSON payload!'

            else:
                reason = 'Call failed because of server timeout!'

            loading_bar.print(
                '%s\nWill wait for %s before attempting again.' %
                (reason,
                 prettyprint_seconds(retry_state.idle_for, granularity=2)))
Exemplo n.º 3
0
        def callback(retry_state):
            exc = retry_state.outcome.exception()
            pretty_time = prettyprint_seconds(retry_state.idle_for, granularity=2)

            exc_name = '%s.%s' % (
                exc.__class__.__module__,
                exc.__class__.__name__
            )

            msg = '\n'.join([
                'Failed attempt because of following exception:',
                exc_name,
                'Will wait for %s before attempting again.' % pretty_time,
                ''
            ])

            self.print(msg)