(self)
| 459 | raise |
| 460 | |
| 461 | async def run(self) -> None: |
| 462 | while self.running: |
| 463 | try: |
| 464 | if self.session_view.needs_export("session"): |
| 465 | self.session_view.mark_auto_export_session() |
| 466 | LOGGER.debug(f"Writing session view to cache {self.path}") |
| 467 | data = serialize_session_view( |
| 468 | self.session_view, |
| 469 | cell_ids=self.document.cell_ids, |
| 470 | script_metadata_hash=_script_metadata_hash( |
| 471 | self.notebook_path |
| 472 | ), |
| 473 | drop_virtual_file_outputs=True, |
| 474 | ) |
| 475 | if isinstance(self.path, AsyncPath): |
| 476 | await self.path.write_text(json.dumps(data, indent=2)) |
| 477 | else: |
| 478 | self.path.write_text(json.dumps(data, indent=2)) |
| 479 | await asyncio.sleep(self.interval) |
| 480 | except asyncio.CancelledError: |
| 481 | raise |
| 482 | except Exception as e: |
| 483 | LOGGER.error(f"Write error: {e}") |
| 484 | # If we fail to write, we should stop the writer |
| 485 | break |
| 486 | |
| 487 | |
| 488 | @dataclass |
no test coverage detected