[Bug] `workflow.wait` broken with `asyncio.FIRST_COMPLETED` and local activities

Abierto
#699 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

Comienza con la reproducción mínima enlazada y el manejo de workflow.wait de Python SDK para actividades locales, comparándolo con actividades no locales. Reproduce el caso FIRST_COMPLETED usando los comandos y las marcas de tiempo indicados, y verifica después que la espera retorna cuando finaliza la primera actividad local y que las actividades restantes se pueden cancelar.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
What are you really trying to do?

Start N local activities, wait for the first one to finish, cancel the others.

Describe the bug

If I start N local activities, then use workflow.wait(tasks, return_when=asyncio.FIRST_COMPLETED), the workflow.wait coro blocks until all of the activities actually finish, instead of returning when the first one finishes. If I use non-local activities, this bug does not happen.

Minimal Reproduction

https://github.com/andmis/snippets/tree/temporal-python-sdk-local-activity-workflow-wait-bug

# Worker output after `python run_workflow.py`
2024-12-09 19:02:30.750775+00:00 (Workflow) Starting, local=False
2024-12-09 19:02:30.750775+00:00 (Workflow) Waiting for first completed activity
2024-12-09 11:02:30.760073 (Activity 0) Running sandbox_activity
2024-12-09 11:02:30.760565 (Activity 1) Running sandbox_activity
2024-12-09 11:02:32.875597 (Activity 1) Exiting sandbox_activity
2024-12-09 19:02:32.891753+00:00 (Workflow) Got first completed activity, cancelling others and exiting
2024-12-09 19:02:32.891753+00:00 (Workflow) Exiting
2024-12-09 11:02:35.328912 (Activity 0) Cancelling sandbox_activity

# Worker output after `python run_workflow.py -l`
2024-12-09 19:03:48.421271+00:00 (Workflow) Starting, local=True
2024-12-09 19:03:48.421271+00:00 (Workflow) Waiting for first completed activity
2024-12-09 11:03:48.425911 (Activity 0) Running sandbox_activity
2024-12-09 11:03:48.426165 (Activity 1) Running sandbox_activity
2024-12-09 11:03:49.817020 (Activity 1) Exiting sandbox_activity
2024-12-09 11:03:56.397142 (Activity 0) Exiting sandbox_activity
2024-12-09 19:03:56.394210+00:00 (Workflow) Got first completed activity, cancelling others and exiting
2024-12-09 19:03:56.394210+00:00 (Workflow) Exiting
# Note the timestamps
Environment/Versions
  • OS and processor: macOS, M1
  • Temporal version: 1.1.2
  • Python SDK version: 1.8.0
  • Are you using Docker or Kubernetes or building Temporal from source? No
Additional context
Lenguaje dominante
Python
Estrellas
1.2k
Forks
241
Merge medio
3 d 2 h
PR fusionados (30 d)
49

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de temporalio/sdk-python

Todos los issues de temporalio/sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.