In Python synchronous activity, how can I avoid retrying after a timeout?

In Python synchronous activity, how can I avoid retrying after a timeout? And attempt cannot be 1. The purpose is: a synchronous interface is only executed once and written to the database. If it times out, it can try and write to the database. No second activity can be run at the same time. If the process hangs, the activity needs to be rerun.

Hi

What is the maximum time the activity can take? You can consider activity heartbeat , if a heartbeat is sent after the timeout, it will throw an error and you can fail the activity .

Another option is to set the DB request timeout to match activity.info().start_to_close_timeout (or slightly less).

Antonio

Thanks for your answer. I think the heartbeat setting can meet my needs. Here is another question: ① Does setting the cancellation_type in execute_activity to WAIT_CANCELLATION_COMPLETED have any effect? I tried various methods and didn’t find any special performance issues.

yes, can you share what you tried?

"""Wait for activity cancellation completion. Note that activity must heartbeat to receive a
cancellation notification. This can block the cancellation for a long time if activity
doesn't heartbeat or chooses to ignore the cancellation request.
"""

is the activity heartbeating? is the code re-throwing the error ?

Antonio