Skip to content

Commit 5d6ae81

Browse files
committed
fix(utils/concurrent_task_runner): error handling
1 parent cab21be commit 5d6ae81

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

npiai/tools/email_organizer/__test__/invoice_organizer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ async def main():
1717
async with EmailOrganizer(provider=Outlook(creds)) as tool:
1818
email_list = [email async for email in tool.list_inbox_stream(limit=10)]
1919

20-
for email in email_list:
21-
print(await tool._to_compact_email_with_pdf_attachments(email))
22-
2320
print("Raw email list:", json.dumps(email_list, indent=4, ensure_ascii=False))
2421

2522
filtered_emails = []

npiai/utils/concurrent_task_runner.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import asyncio
2+
import sys
3+
import traceback
24
from typing import Callable, Awaitable, Any, AsyncGenerator
35

46

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

1820
async def process():
19-
await fn(results_queue)
21+
try:
22+
await fn(results_queue)
23+
except Exception:
24+
print(
25+
f"Error in concurrent_task_runner: {traceback.format_exc()}",
26+
file=sys.stderr,
27+
)
2028

2129
async def task_runner():
2230
nonlocal running_task_count

0 commit comments

Comments
 (0)