# How does the Temporal Python SDK inject exceptions into a thread?

**URL:** https://community.temporal.io/t/how-does-the-temporal-python-sdk-inject-exceptions-into-a-thread/18080
**Category:** Community Support
**Tags:** python-sdk, activity
**Created:** [August 1, 2025, 7:54am UTC](https://community.temporal.io/t/how-does-the-temporal-python-sdk-inject-exceptions-into-a-thread/18080 "2025-08-01T07:54:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hao\_xie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/hao_xie/32/7587_2.png) [@hao\_xie](https://community.temporal.io/u/hao_xie)
#### Post date: [August 1, 2025, 7:54am UTC](https://community.temporal.io/t/how-does-the-temporal-python-sdk-inject-exceptions-into-a-thread/18080/1 "2025-08-01T07:54:05Z")

</div>

How does the Temporal Python SDK inject exceptions into a thread? When I use Temporal for a synchronous function, I need to start a thread to execute the synchronous function. The main thread loops to send heartbeats and check whether to exit. Exception injection is very helpful for terminating the synchronous function thread early. Note: I cannot perform any instrumentation in the synchronous function.
