samples-python icon indicating copy to clipboard operation
samples-python copied to clipboard

Use `asyncio.to_thread` to avoid `DeadlockError` while sending exception to Sentry

Open Natim opened this issue 2 months ago • 3 comments

What was changed

Make the capture_exception call async in Sentry intercepor

Why?

Use asyncio.to_thread to avoid DeadlockError while sending exception to Sentry

Checklist

  1. Refs #140

  2. How was this tested: In production _DeadlockError was raised

  3. Any docs updates needed? No

Natim avatar Dec 17 '25 10:12 Natim

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 17 '25 10:12 CLAassistant

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Dec 17 '25 10:12 CLAassistant

Well, well

  File "/app/project/temporal/interceptor.py", line 129, in execute_workflow
    await asyncio.to_thread(scope.capture_exception, e)

  File "/usr/local/lib/python3.14/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
                 ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.14/asyncio/events.py", line 337, in run_in_executor
    raise NotImplementedError

Natim avatar Dec 17 '25 16:12 Natim