File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
backend/infrahub/task_manager Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 55
66from prefect .client .orchestration import PrefectClient , get_client
77from prefect .events .schemas .events import Event as PrefectEventModel
8+ from prefect .exceptions import PrefectHTTPStatusError
89from pydantic import BaseModel , Field , TypeAdapter
910
1011from infrahub .core .constants import GLOBAL_BRANCH_NAME
@@ -220,14 +221,17 @@ async def query_events(
220221
221222 # Retry due to https://github.com/PrefectHQ/prefect/issues/16299
222223 for _ in range (1 , 5 ):
223- response = await client ._client .post ("/infrahub/events/filter" , json = body )
224- if response .status_code == 200 :
224+ prefect_error : PrefectHTTPStatusError | None = None
225+ try :
226+ response = await client ._client .post ("/infrahub/events/filter" , json = body )
225227 break
226- await asyncio .sleep (0.1 )
228+ except PrefectHTTPStatusError as exc :
229+ prefect_error = exc
230+ await asyncio .sleep (0.1 )
227231
228- if response . status_code != 200 :
232+ if prefect_error :
229233 raise ServiceUnavailableError (
230- message = f"Unable to query prefect due to invalid response from the server (status_code={ response .status_code } )"
234+ message = f"Unable to query prefect due to invalid response from the server (status_code={ prefect_error . response .status_code } )"
231235 )
232236 data : dict [str , Any ] = response .json ()
233237
You can’t perform that action at this time.
0 commit comments