@@ -88,6 +88,11 @@ async def get_job(session: ClientSession, retry=True) -> Optional[Dict[str, Any]
8888 else :
8989 next_job = received_request
9090
91+ except asyncio .TimeoutError :
92+ log .debug ("Timeout error, retrying." )
93+ if retry is False :
94+ break
95+
9196 except Exception as err : # pylint: disable=broad-except
9297 err_type = type (err ).__name__
9398 err_message = str (err )
@@ -102,8 +107,6 @@ async def get_job(session: ClientSession, retry=True) -> Optional[Dict[str, Any]
102107
103108 await asyncio .sleep (1 )
104109 else :
105- log .debug ("Confirmed valid request." , next_job ['id' ])
106-
107110 job_list .add_job (next_job ["id" ])
108111 log .debug ("Request ID added." , next_job ['id' ])
109112
@@ -115,10 +118,16 @@ async def get_job(session: ClientSession, retry=True) -> Optional[Dict[str, Any]
115118async def run_job (handler : Callable , job : Dict [str , Any ]) -> Dict [str , Any ]:
116119 """
117120 Run the job using the handler.
118- Returns the job output or error.
121+
122+ Args:
123+ handler (Callable): The handler function to use.
124+ job (Dict[str, Any]): The job to run.
125+
126+ Returns:
127+ Dict[str, Any]: The result of running the job.
119128 """
120- log .info ('Started' , job ["id" ])
121- run_result = {"error" : "No output from handler." }
129+ log .info ('Started. ' , job ["id" ])
130+ run_result = {}
122131
123132 try :
124133 handler_return = handler (job )
@@ -129,8 +138,7 @@ async def run_job(handler: Callable, job: Dict[str, Any]) -> Dict[str, Any]:
129138 if isinstance (job_output , dict ):
130139 error_msg = job_output .pop ("error" , None )
131140 refresh_worker = job_output .pop ("refresh_worker" , None )
132-
133- run_result = {"output" : job_output }
141+ run_result ['output' ] = job_output
134142
135143 if error_msg :
136144 run_result ["error" ] = error_msg
0 commit comments