From a34d750152c5afc35c82737f2578de1979910dc9 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sun, 5 Aug 2018 07:58:25 +0200 Subject: [PATCH] rate handling: Show %H:%M when request is retried --- instaloader/instaloadercontext.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index d7b65a3..7cf4700 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -9,6 +9,7 @@ import textwrap import time import urllib.parse from contextlib import contextmanager +from datetime import datetime, timedelta from typing import Any, Callable, Dict, Iterator, Optional import requests @@ -246,7 +247,8 @@ class InstaloaderContext: if is_graphql_query and not query_not_limited: waittime = graphql_query_waittime() if waittime > 0: - self.log('\nToo many queries in the last time. Need to wait {} seconds.'.format(waittime)) + self.log('\nToo many queries in the last time. Need to wait {} seconds, until {:%H:%M}.' + .format(waittime, datetime.now() + timedelta(seconds=waittime))) time.sleep(waittime) if self.query_timestamps is not None: self.query_timestamps.append(time.monotonic()) @@ -301,7 +303,8 @@ class InstaloaderContext: if is_graphql_query: waittime = graphql_query_waittime(untracked_queries=True) if waittime > 0: - self.log('The request will be retried in {} seconds.'.format(waittime)) + self.log('The request will be retried in {} seconds, at {:%H:%M}.' + .format(waittime, datetime.now() + timedelta(seconds=waittime))) time.sleep(waittime) self._sleep() return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1)