For a specific task I have 2 workflows that maintain some state attributes to manage the process state between interactions. The 2 workflows also execute activities that interface with my API. I want my API to be able to signal to these workflows to set the state if my API comes to specific conclusions about the client processes.
I am running into deadlock errors on my workers which I believe is coming from some workflow signal methods that are setting the state of the workflow itself.
@workflow.signal
async def set_user_state(self, state: str):
if state not in UserState:
workflow.logger.error(f"Invalid user state: {state}")
return
previous_state = self.user_state
self.user_state = state
if self.user_state != UserState.NORMAL.value:
self.progress = CheckInStatus.IDLE.value
elif previous_state != UserState.NORMAL.value and self.user_state == UserState.NORMAL.value:
# Reset progress when returning to NORMAL state
self.progress = CheckInStatus.IDLE.value
It seems like this goes against the core Temporal server code. What should I be doing instead if I want my API to be able to signal to the workflow that something specific has occurred and update the workflow state so that specific actions can occur as a result? (i.e. in this case I signal the user state which allows the workflow to execute in a specific way due to that state change).