Coroutine getting lost after sleep
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 50/100
Línea de trabajo
Comienza con el método items de GeneratorQueryHandler del reproductor mínimo y observa su comportamiento mientras escribes "chunktest asdf" rápidamente. Compara dormir después del yield con dormir antes de él, y sigue cómo se gestionan la cancelación de la coroutine y ctx.isValid. Se considera terminado cuando los cinco chunks de elementos siguen rellenándose después de un sleep posterior al yield sin perder la coroutine.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I'm working on a plugin with a GeneratorQueryHandler which yields one item as a result, and then sleeps for a bit, and then fetches a result from an API and yields those items as well. So basically, it yields two chunks:
- "Web search"
- First 5 results of the suggestions
But I've noticed that the coroutine seems to just stop getting called sometimes. I was able to boil it down to a minimal reproducer:
import time
from albert import *
md_iid = "5.0"
md_name = "chunktest"
md_description = "testing multiple chunks of items"
md_authors = ["@brenns10"]
class Plugin(PluginInstance, GeneratorQueryHandler):
def __init__(self):
PluginInstance.__init__(self)
GeneratorQueryHandler.__init__(self)
def defaultTrigger(self):
return "chunktest "
def items(self, ctx):
for i in range(5):
if not ctx.isValid:
info("exiting early")
return
info(f"yielding item {i}")
yield [
StandardItem(
id=f"item{i}",
text=f"Item {i}",
subtext="details",
actions=[
Action(
id="act",
text="Open Google",
callable=lambda: runTerminal("echo hi"),
)
],
)
]
time.sleep(0.1)
info("finished sleeping")
info("done")
When I load this plugin, and then type "chunktest asdf" (type really fast), I only get "Item 0", and the logs look like this:
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [warn:albert.wbm] Item retured null icon: python.chunktest.item0
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [info:albert.python.chunktest] finished sleeping
17:25:52 [info:albert.python.chunktest] yielding item 1
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:52 [info:albert.python.chunktest] yielding item 0
17:25:53 [info:albert.python.chunktest] yielding item 0
17:25:53 [info:albert.python.chunktest] yielding item 0
The remaining 4 items never get populated. Here is a video that shows what I mean.
However, if you go ahead and move the time.sleep() call just before the yield statement, rather than after it, you'll get the behavior I expect. That is, the results keep getting replaced each time I type a new keystroke, and they slowly populate whenever I pause. Here's the video of this behavior.
It seems to me like there's something going on with this time.sleep() call directly after the yield. I notice I never see the "exiting early" message logged, which may or may not be related.
- Lenguaje dominante
- C++
- Estrellas
- 3
- Forks
- 4
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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.
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
Los mantenedores suelen responder en 1 día
-
(S1 - Need confirmation)
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
CleverRaven/Cataclysm-DDA#89159 ·
Los mantenedores suelen responder en 1 día
-
area:libnvmpi bug P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
gjrtimmer/jetson-nvmpi#33 ·
-
bug(wasi_crypto): ArrayOutput::pull reports the wrong all-pulled flagPosiblemente ocupada @Yashbhu la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
bug question
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100