| 1302 | |
| 1303 | @work |
| 1304 | async def _run_worker(self) -> None: |
| 1305 | try: |
| 1306 | if isinstance(self._main, InstanceRunnable): |
| 1307 | result: ValueT | None = await self._main.run() |
| 1308 | else: |
| 1309 | result = await self._main() |
| 1310 | |
| 1311 | tui.exit(result) |
| 1312 | except WorkerCancelled: |
| 1313 | debug('Worker was cancelled') |
| 1314 | except Exception as err: |
| 1315 | debug(f'Error while running main app: {err}') |
| 1316 | # this will terminate the textual app and return the exception |
| 1317 | self.exit(cast(ValueT, err)) |
| 1318 | |
| 1319 | @work |
| 1320 | async def _show_async(self, screen: Screen[Result[ValueT]]) -> Result[ValueT]: |