Closed medunea closed 4 months ago
async def _check_rep(self, rep: Response) -> None:
"""
This function can raise Exception and request will be retried or aborted
Or if None is returned, response will passed to api parser as is
"""
...
...
if err_msg != "OK":
logger.warning(f"API unknown error: {log_msg}")
return # ignore any other unknown errors
I suggest adding the code below to the above code to prevent unknown errors from repeatedly requesting the same account thousands of times.
await self._close_ctx(utc.ts() + 60 * 15) # 15 minutes
raise HandledError()
Or just solve this problem
if err_msg.startswith("(64) Your account is suspended and is not permitted to access this feature"):
logger.warning(f"Session expired or banned: {log_msg}")
await self._close_ctx(-1, inactive=True, msg=err_msg)
raise HandledError()
Use Function
api.following(user_id, limit=limit)
Log
2024-01-31 02:35:45.110 | WARNING | twscrape.queue_client:_check_rep:184 - API unknown error: 403 - 488/500 - acbiesuper17982 - (64) Your account is suspended and is not permitted to access this feature. 2024-01-31 02:36:49.517 | WARNING | twscrape.queue_client:_check_rep:184 - API unknown error: 403 - 487/500 - acbiesuper17982 - (64) Your account is suspended and is not permitted to access this feature. 2024-01-31 02:37:54.000 | WARNING | twscrape.queue_client:_check_rep:184 - API unknown error: 403 - 486/500 - acbiesuper17982 - (64) Your account is suspended and is not permitted to access this feature.
Once an account encounters this situation, it will continue to use that account for requests, resulting in the program being unable to continue running