[O] Move rate delay to the end
This commit is contained in:
@@ -163,6 +163,9 @@ def download_users(api: API, start_point: str, n: float = math.inf,
|
|||||||
Path(f'{base_dir}/users').mkdir(parents=True, exist_ok=True)
|
Path(f'{base_dir}/users').mkdir(parents=True, exist_ok=True)
|
||||||
Path(f'{base_dir}/meta').mkdir(parents=True, exist_ok=True)
|
Path(f'{base_dir}/meta').mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# Rate limit delay
|
||||||
|
rate_delay = 1 / rate_limit * 60 + 0.1
|
||||||
|
|
||||||
# Set of all the downloaded users' screen names
|
# Set of all the downloaded users' screen names
|
||||||
downloaded = set()
|
downloaded = set()
|
||||||
|
|
||||||
@@ -177,9 +180,6 @@ def download_users(api: API, start_point: str, n: float = math.inf,
|
|||||||
|
|
||||||
# Loop until there are enough users
|
# Loop until there are enough users
|
||||||
while len(downloaded) < n:
|
while len(downloaded) < n:
|
||||||
# Rate limit
|
|
||||||
time.sleep(1 / rate_limit * 60 + 0.1)
|
|
||||||
|
|
||||||
# Take a screen name from the current list
|
# Take a screen name from the current list
|
||||||
screen_name = current_set.pop()
|
screen_name = current_set.pop()
|
||||||
|
|
||||||
@@ -235,6 +235,9 @@ def download_users(api: API, start_point: str, n: float = math.inf,
|
|||||||
debug(f'Finished saving friends of {screen_name}')
|
debug(f'Finished saving friends of {screen_name}')
|
||||||
debug(f'============= Total {len(downloaded)} saved =============')
|
debug(f'============= Total {len(downloaded)} saved =============')
|
||||||
|
|
||||||
|
# Rate limit
|
||||||
|
time.sleep(rate_delay)
|
||||||
|
|
||||||
|
|
||||||
def convert_to_generic(username: str, tweet: Tweet) -> Posting:
|
def convert_to_generic(username: str, tweet: Tweet) -> Posting:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user