Skip to content

Commit 9c22bec

Browse files
committed
Drive-by: get rid of always-true condition
1 parent 84b184f commit 9c22bec

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

temporalio/worker/_workflow.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -285,34 +285,33 @@ async def _handle_activation(
285285

286286
# Run activation in separate thread so we can check if it's
287287
# deadlocked
288-
if workflow:
289-
activate_task = asyncio.get_running_loop().run_in_executor(
290-
self._workflow_task_executor,
291-
workflow.activate,
292-
act,
293-
)
288+
activate_task = asyncio.get_running_loop().run_in_executor(
289+
self._workflow_task_executor,
290+
workflow.activate,
291+
act,
292+
)
294293

295-
# Run activation task with deadlock timeout
296-
try:
297-
completion = await asyncio.wait_for(
298-
activate_task, self._deadlock_timeout_seconds
299-
)
300-
except asyncio.TimeoutError:
301-
# Need to create the deadlock exception up here so it
302-
# captures the trace now instead of later after we may have
303-
# interrupted it
304-
deadlock_exc = _DeadlockError.from_deadlocked_workflow(
305-
workflow.instance, self._deadlock_timeout_seconds
306-
)
307-
# When we deadlock, we will raise an exception to fail
308-
# the task. But before we do that, we want to try to
309-
# interrupt the thread and put this activation task on
310-
# the workflow so that the successive eviction can wait
311-
# on it before trying to evict.
312-
workflow.attempt_deadlock_interruption()
313-
# Set the task and raise
314-
workflow.deadlocked_activation_task = activate_task
315-
raise deadlock_exc from None
294+
# Run activation task with deadlock timeout
295+
try:
296+
completion = await asyncio.wait_for(
297+
activate_task, self._deadlock_timeout_seconds
298+
)
299+
except asyncio.TimeoutError:
300+
# Need to create the deadlock exception up here so it
301+
# captures the trace now instead of later after we may have
302+
# interrupted it
303+
deadlock_exc = _DeadlockError.from_deadlocked_workflow(
304+
workflow.instance, self._deadlock_timeout_seconds
305+
)
306+
# When we deadlock, we will raise an exception to fail
307+
# the task. But before we do that, we want to try to
308+
# interrupt the thread and put this activation task on
309+
# the workflow so that the successive eviction can wait
310+
# on it before trying to evict.
311+
workflow.attempt_deadlock_interruption()
312+
# Set the task and raise
313+
workflow.deadlocked_activation_task = activate_task
314+
raise deadlock_exc from None
316315

317316
except Exception as err:
318317
if isinstance(err, _DeadlockError):

0 commit comments

Comments
 (0)