Refactor logging and improve async iteration in report generation
Refactored `CustomLogsHandler` to accept an optional logs list and modified its method to append data instead of yielding. Enhanced `ReportGenerator` with proper asynchronous iterator implementation, enabling smooth log handling and retrieval. Simplified variable naming for better readability.
This commit is contained in:
parent
cd79fe99be
commit
14429fc6f7
2 changed files with 28 additions and 9 deletions
|
@ -36,9 +36,9 @@ async def get_report_endpoint(request: ReportRequest):
|
|||
async def generate_report():
|
||||
try:
|
||||
# Call the asynchronous get_report function
|
||||
report_generator = ReportGenerator(request.query, request.report_type)
|
||||
async for chunk in report_generator:
|
||||
yield chunk
|
||||
generator = ReportGenerator(request.query, request.report_type)
|
||||
async for log in generator:
|
||||
yield log
|
||||
except Exception as e:
|
||||
yield f"Error: {str(e)}"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue