def _log_rate_limit(self, future):
        try:
            r = future.result()
        except HTTPError as e:
            r = e.response
            if r is None:
                # some errors don't have a response (e.g. failure to build request)
                return
        limit_s = r.headers.get('X-RateLimit-Limit', '')
        remaining_s = r.headers.get('X-RateLimit-Remaining', '')
        if not remaining_s or not limit_s:
            if r.code < 300:
                app_log.warn("No rate limit headers. Did GitHub change? %s",
                    json.dumps(dict(r.headers), indent=1)
                )
            return
        
        remaining = int(remaining_s)
        limit = int(limit_s)
        if remaining == 0:
            jsondata = response_text(r)
            data = json.loads(jsondata)
            app_log.error("GitHub rate limit (%s) exceeded: %s", limit, data.get('message', 'no message'))
            return
        
        if 10 * remaining > limit:
            log = app_log.debug
        else:
            log = app_log.warn
        log("%i/%i GitHub API requests remaining", remaining, limit)
Batchwise dot product.
dataset/ETHPy150Open jupyter/nbviewer/nbviewer/providers/github/client.py/AsyncGitHubClient._log_rate_limit--crossover with--dataset/ETHPy150Open fchollet/keras/keras/backend/tensorflow_backend.py/batch_dot