Coroutine getting lost after sleep
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
Direzione di ricerca
Inizia con il metodo items di GeneratorQueryHandler del riproduttore minimo e osservane il comportamento mentre digiti rapidamente "chunktest asdf". Confronta l'attesa dopo il yield con l'attesa prima di esso e traccia come vengono gestiti l'annullamento della coroutine e ctx.isValid. Il lavoro è completato quando tutti e cinque i chunk di elementi continuano a popolarsi dopo un sleep post-yield senza perdere la coroutine.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C++
- Stelle
- 3
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
rocketride-org/rocketride-server#2705 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ROCm/rocm-systems#13754 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
neutralinojs/neutralinojs#1861 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
raspberrypi/libpisp#80 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nanoporetech/pod5-file-format#198 ·