-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Implement PDF Report Streaming from Storage #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ class Settings(BaseSettings): | |
| TEST_DB_NAME: str | None = None | ||
|
|
||
| BASE_DIR: Path = Path(__file__).parent.parent.parent | ||
| REPORT_OUTPUT_DIR: Path = BASE_DIR / "reports_output" | ||
| REPORT_OUTPUT_DIR: Path = BASE_DIR / "storage" / "reports" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Missing import for The Add the missing import at the top of the file: from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Dict, List
+from pathlib import Path🧰 Tools🪛 Ruff (0.14.8)54-54: Undefined name (F821) 🤖 Prompt for AI Agents |
||
|
|
||
| model_config = SettingsConfigDict(env_file=".env") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Race condition: concurrent PDF generation for the same report.
When multiple requests arrive simultaneously for a report that doesn't have a cached PDF, all requests will pass the
pdf_filepath.exists()check and attempt to generate the PDF concurrently. This can lead to:Consider using file-based locking or an in-memory lock (e.g., using
asyncio.Lockstored in a dictionary keyed by report_id) to ensure only one request generates the PDF at a time, while others wait for the generation to complete.Example approach using asyncio locks:
🤖 Prompt for AI Agents