File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed
packages/service-library/src/servicelib
aiohttp/long_running_tasks
fastapi/long_running_tasks Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 1+ import logging
2+
13from aiohttp import web
24
35from ...json_serialization import json_dumps
79 TaskNotFoundError ,
810)
911
12+ _logger = logging .getLogger (__name__ )
13+
1014
1115@web .middleware
1216async def base_long_running_error_handler (request , handler ):
1317 try :
1418 return await handler (request )
1519 except (TaskNotFoundError , TaskNotCompletedError ) as exc :
20+ _logger .debug ("" , exc_info = True )
1621 error_fields = dict (code = exc .code , message = f"{ exc } " )
1722 raise web .HTTPNotFound (
1823 reason = f"{ json_dumps (error_fields )} " ,
1924 ) from exc
2025 except TaskCancelledError as exc :
2126 # NOTE: only use-case would be accessing an already cancelled task
2227 # which should not happen, so we return a conflict
28+ _logger .debug ("" , exc_info = True )
2329 error_fields = dict (code = exc .code , message = f"{ exc } " )
2430 raise web .HTTPConflict (reason = f"{ json_dumps (error_fields )} " ) from exc
Original file line number Diff line number Diff line change 1+ import logging
2+
13from fastapi import status
24from fastapi .encoders import jsonable_encoder
35from starlette .requests import Request
911 TaskNotFoundError ,
1012)
1113
14+ _logger = logging .getLogger (__name__ )
15+
1216
1317async def base_long_running_error_handler (
1418 _ : Request , exception : BaseLongRunningError
1519) -> JSONResponse :
20+ _logger .debug ("%s" , exception , stack_info = True )
1621 error_fields = dict (code = exception .code , message = f"{ exception } " )
1722 status_code = (
1823 status .HTTP_404_NOT_FOUND
Original file line number Diff line number Diff line change @@ -316,12 +316,8 @@ async def remove_task(
316316 reraise_errors : bool = True ,
317317 ) -> None :
318318 """cancels and removes task"""
319- logger .debug (
320- "Attempting to remove task with task_id=%s." , task_id , exc_info = True
321- )
322319 try :
323320 tracked_task = self ._get_tracked_task (task_id , with_task_context )
324- logger .debug ("Succeeded in getting task with task_id=%s" , task_id )
325321 except TaskNotFoundError :
326322 if reraise_errors :
327323 raise
@@ -330,10 +326,8 @@ async def remove_task(
330326 await self ._cancel_tracked_task (
331327 tracked_task .task , task_id , reraise_errors = reraise_errors
332328 )
333- logger .debug ("Succeeded in canceling task with task_id=%s" , task_id )
334329 finally :
335330 del self ._tasks_groups [tracked_task .task_name ][task_id ]
336- logger .debug ("Removed task_id=%s from tracked tasks" , task_id )
337331
338332 async def close (self ) -> None :
339333 """
You can’t perform that action at this time.
0 commit comments