Asynchronously generate a PDF alongside md_path. Runs reportlab in a thread executor so the asyncio event loop is not blocked. Returns ------- Path | None Path to the generated PDF on success, ``None`` if skipped or failed.
(md_path: Path)
| 164 | |
| 165 | |
| 166 | async def generate_pdf_report(md_path: Path) -> Path | None: |
| 167 | """ |
| 168 | Asynchronously generate a PDF alongside md_path. |
| 169 | |
| 170 | Runs reportlab in a thread executor so the asyncio event loop |
| 171 | is not blocked. |
| 172 | |
| 173 | Returns |
| 174 | ------- |
| 175 | Path | None |
| 176 | Path to the generated PDF on success, ``None`` if skipped or failed. |
| 177 | """ |
| 178 | pdf_path = md_path.with_suffix(".pdf") |
| 179 | date_str = datetime.now().strftime("%Y-%m-%d") |
| 180 | loop = asyncio.get_event_loop() |
| 181 | try: |
| 182 | await loop.run_in_executor(None, _generate_pdf_sync, md_path, pdf_path, date_str) |
| 183 | return pdf_path if pdf_path.exists() else None |
| 184 | except Exception: |
| 185 | logger.exception("PDF generation failed for %s.", md_path) |
| 186 | return None |
no outgoing calls