mirror of
				https://github.com/catspace-dev/unicheckbot.git
				synced 2025-11-04 01:17:30 +03:00 
			
		
		
		
	result Response(500) if node unreachable
This commit is contained in:
		
							parent
							
								
									cd2e0002f8
								
							
						
					
					
						commit
						9ca48f5973
					
				| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
from httpx import AsyncClient, Timeout
 | 
			
		||||
from httpx import AsyncClient, Timeout, Response, ConnectError
 | 
			
		||||
from typing import List
 | 
			
		||||
from core.coretypes import APINode
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,8 +15,12 @@ def check_int(value) -> bool:
 | 
			
		|||
async def send_api_requests(endpoint: str, data: dict, nodes: List[APINode]):
 | 
			
		||||
    for node in nodes:
 | 
			
		||||
        data.update(dict(token=node.token))
 | 
			
		||||
        try:
 | 
			
		||||
            async with AsyncClient(timeout=Timeout(timeout=100.0)) as client:
 | 
			
		||||
                result = await client.get(
 | 
			
		||||
                    f"{node.address}/{endpoint}", params=data
 | 
			
		||||
                )
 | 
			
		||||
        except ConnectError:
 | 
			
		||||
            # We yield 500 response when backend is offline
 | 
			
		||||
            result = Response(500)
 | 
			
		||||
        yield result
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user