зеркало из
				https://github.com/viginum-datalab/twscrape.git
				synced 2025-10-30 13:36:12 +02:00 
			
		
		
		
	Handle unknown authorization error with status 200
Этот коммит содержится в:
		
							родитель
							
								
									e9152a1186
								
							
						
					
					
						Коммит
						df94e77295
					
				| @ -38,11 +38,14 @@ class RateLimitError(Exception): | |||||||
| class BannedError(Exception): | class BannedError(Exception): | ||||||
|     pass |     pass | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class DependencyError(Exception): | class DependencyError(Exception): | ||||||
|     pass |     pass | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | class UnknownAuthorizationError(Exception): | ||||||
|  |     pass | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def req_id(rep: httpx.Response): | def req_id(rep: httpx.Response): | ||||||
|     lr = str(rep.headers.get("x-rate-limit-remaining", -1)) |     lr = str(rep.headers.get("x-rate-limit-remaining", -1)) | ||||||
|     ll = str(rep.headers.get("x-rate-limit-limit", -1)) |     ll = str(rep.headers.get("x-rate-limit-limit", -1)) | ||||||
| @ -170,6 +173,9 @@ class QueueClient: | |||||||
|         if rep.status_code == 200 and "_Missing: No status found with that ID." in msg: |         if rep.status_code == 200 and "_Missing: No status found with that ID." in msg: | ||||||
|             return  # ignore this error |             return  # ignore this error | ||||||
| 
 | 
 | ||||||
|  |         if rep.status_code == 200 and "Authorization: Denied by access control: unspecified reason" in msg: | ||||||
|  |             raise UnknownAuthorizationError(msg) | ||||||
|  | 
 | ||||||
|         # todo: (32) Could not authenticate you |         # todo: (32) Could not authenticate you | ||||||
| 
 | 
 | ||||||
|         if msg != "OK": |         if msg != "OK": | ||||||
| @ -197,7 +203,10 @@ class QueueClient: | |||||||
|                 # already handled |                 # already handled | ||||||
|                 continue |                 continue | ||||||
|             except DependencyError: |             except DependencyError: | ||||||
|                 logger.error(f"Dependency error, returnning: {url}") |                 logger.error(f"Dependency error, returning: {url}") | ||||||
|  |                 return | ||||||
|  |             except UnknownAuthorizationError: | ||||||
|  |                 logger.error(f"Unknown authorization error, returning: {url}") | ||||||
|                 return |                 return | ||||||
|             except (httpx.ReadTimeout, httpx.ProxyError): |             except (httpx.ReadTimeout, httpx.ProxyError): | ||||||
|                 # http transport failed, just retry |                 # http transport failed, just retry | ||||||
|  | |||||||
		Загрузка…
	
	
			
			x
			
			
		
	
		Ссылка в новой задаче
	
	Block a user
	 Niels Ørbæk Chemnitz
						Niels Ørbæk Chemnitz