Skip to content

Commit

Permalink
improve error handling for thread-based processes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Jun 5, 2023
1 parent cbd1f6c commit 0235dec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion yente/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ async def refresh_catalog() -> None:

async def update_in_thread() -> None:
log.info("Refreshing manifest/catalog...", catalog=Catalog.instance)
Catalog.instance = await Catalog.load()
try:
Catalog.instance = await Catalog.load()
except (Exception, KeyboardInterrupt) as exc:
log.exception("Metadata fetch error: %s" % exc)

thread = threading.Thread(
target=asyncio.run,
Expand Down
5 changes: 4 additions & 1 deletion yente/search/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ async def update_index(force: bool = False) -> bool:

def update_index_threaded(force: bool = False) -> None:
async def update_in_thread() -> None:
await update_index(force=force)
try:
await update_index(force=force)
except (Exception, KeyboardInterrupt) as exc:
log.exception("Index update error: %s" % exc)

thread = threading.Thread(
target=asyncio.run,
Expand Down

0 comments on commit 0235dec

Please sign in to comment.