# Heartbeating for python synchronous activities

**URL:** <https://community.temporal.io/t/heartbeating-for-python-synchronous-activities/16801>\
**Category:** Community Support\
**Tags:** python-sdk\
**Created:** [March 14, 2025, 3:48pm UTC](https://community.temporal.io/t/heartbeating-for-python-synchronous-activities/16801 "2025-03-14T15:48:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varun\_Tupuri](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/varun_tupuri/32/6972_2.png) [@Varun\_Tupuri](https://community.temporal.io/u/Varun_Tupuri)\
**Post date:** [March 14, 2025, 3:48pm UTC](https://community.temporal.io/t/heartbeating-for-python-synchronous-activities/16801/1 "2025-03-14T15:48:21Z")

</div>

I have an activity defined like

```auto
@activity.defn
def some_activity(self, request) -> response:
    with register_heartbeat(activity.info()):
        time.sleep(50)
    return response

```

where register\_heartbeat looks like

```auto
@contextmanager
def register_heartbeat(heartbeater: TemporalHeartbeater, task_id: ActivityInfo) -> Iterator[None]:
    try:
        heartbeater.register(task_id)
        yield
    finally:
        heartbeater.unregister(task_id)

```

the TemporalHeartbeater class is responsible for registering, and unregistering tasks and heartbeats on their behalf in the main thread. the code for the heartbeat loop is below

```auto
async def heartbeat_loop(self, heartbeat_interval: timedelta = timedelta(seconds=10)) -> None:
    """Background task that sends heartbeats every 10 seconds."""
    while True:
        for task_id in self._registered:
            handle = self._client.get_async_activity_handle(task_token=task_id.task_token)
            await handle.heartbeat()
        await asyncio.sleep(heartbeat_interval.total_seconds())

```

With this code, I can see the last\_heartbeat getting updated every 10 seconds on the temporal ui. Despite this, **the activity still times out after 30 seconds (my set heartbeat timeout)**

**However, when I make the activity async, the code executes without getting the heartbeat timeout**

Is there a function other than get\_async\_activity\_handle, I’m supposed to be using to heartbeat on behalf of a synchronous activity? Any help would be appreciated!
