Skip to content

Commit

Permalink
fix(utils/concurrent_task_runner): error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
idiotWu committed Dec 26, 2024
1 parent cab21be commit 5d6ae81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 0 additions & 3 deletions npiai/tools/email_organizer/__test__/invoice_organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ async def main():
async with EmailOrganizer(provider=Outlook(creds)) as tool:
email_list = [email async for email in tool.list_inbox_stream(limit=10)]

for email in email_list:
print(await tool._to_compact_email_with_pdf_attachments(email))

print("Raw email list:", json.dumps(email_list, indent=4, ensure_ascii=False))

filtered_emails = []
Expand Down
10 changes: 9 additions & 1 deletion npiai/utils/concurrent_task_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
import sys
import traceback
from typing import Callable, Awaitable, Any, AsyncGenerator


Expand All @@ -16,7 +18,13 @@ async def concurrent_task_runner[
counter_lock = asyncio.Lock()

async def process():
await fn(results_queue)
try:
await fn(results_queue)
except Exception:
print(
f"Error in concurrent_task_runner: {traceback.format_exc()}",
file=sys.stderr,
)

async def task_runner():
nonlocal running_task_count
Expand Down

0 comments on commit 5d6ae81

Please sign in to comment.