Coroutine getting lost after sleep
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 50/100
Hướng nghiên cứu
Bắt đầu với phương thức items của GeneratorQueryHandler trong minimal reproducer và quan sát hành vi của nó khi nhập nhanh "chunktest asdf". So sánh việc sleep sau yield với việc sleep trước yield, đồng thời theo dõi cách xử lý việc hủy coroutine và ctx.isValid. Được coi là hoàn thành khi cả năm item chunk tiếp tục được điền sau một post-yield sleep mà không làm mất coroutine.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 3
- Fork
- 4
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
3.7.6-dev commit 80481ea - files not centered when resolution differs and zoom = "pixel-to-pixel"Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
grizzlypeak3d/DJV#931 ·
-
bug 🔥 pharesee
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
BoundedVector::insert assigns to slots that were never constructedCó thể đã có người làm @auraseb đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
philips-software/amp-embedded-infra-lib#1379 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bot-triaged module: cpp module: deprecation module: optimizer triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày