'cannot reuse already awaited coroutine' with timed_window on Python 3.7.5
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- stream-processing
Línea de trabajo
Start with the timed_window path in streamz/core.py around line 917 and the Sink.update method around line 535. Reproduce the Python 3.7.5 example, then inspect tests/core.py for related asynchronous sink coverage. Done means a regression test demonstrates the repeated-await failure and the chosen fix preserves existing tests.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Using timed_window in Python 3.7.5 can sometimes lead to a coroutine being awaited more than once.
Here's a sample program:
async def my_sink(x):
print(x)
await sleep(2)
# raise Exception("Blah!")
async def main():
source = Stream(asynchronous=True)
source.timed_window(interval=1).sink(my_sink)
for x in range(100):
await source.emit(x)
await sleep(0.2)
if __name__ == "__main__":
run(main(), debug=True)
I narrowed down the reason to the same coroutine being possibly returned more than once in https://github.com/python-streamz/streamz/blob/master/streamz/core.py#L917.
A way to work around this issue is to create a task that runs the coroutine. Modifying the update method of the Sink class to return a task fixes the issue. The tests in tests/core.py continue pass.
diff --git a/streamz/core.py b/streamz/core.py
index fe588ed..6916f19 100644
--- a/streamz/core.py
+++ b/streamz/core.py
@@ -535,7 +535,7 @@ class sink(Stream):
def update(self, x, who=None):
result = self.func(x, *self.args, **self.kwargs)
if gen.isawaitable(result):
- return result
+ return gen.convert_yielded(result)
else:
return []
I'm quite sure this can break something else. What am I missing?
Also, how can we go about writing a test case that demonstrates the issue?
- Lenguaje dominante
- Python
- Estrellas
- 1.3k
- Forks
- 149
- Merge medio
- 17 h 39 min
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-streamz/streamz
-
pkg_resources warning Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
python-streamz/streamz#481 · 4 comentarios ·
-
Combining the streamz.Stream.filenames() and streamz.Stream.from_textfile() using dask scatter? Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
python-streamz/streamz#480 · 2 comentarios ·
-
Compile the code into c++ Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
python-streamz/streamz#479 · 1 comentario ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
python-streamz/streamz#478 · 6 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 10/100
python-streamz/streamz#476 · 17 comentarios · 2 reacciones ·
Todos los issues de python-streamz/streamz
Issues similares
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Abiertoarea: harness bug status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Human-Agent-Society/reef#625 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
learningequality/kolibri#15351 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Name consistency Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eellak/triplestore#65 · 1 comentario ·