Timeout in Notifier does not work as expected
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- networking
调研方向
从 can/bus.py 中链接的 BusABC.recv(timeout) 定义和 can/notifier.py 中的接收循环开始,然后运行提供的 virtual-bus 复现。跟踪在 listener callbacks 之前如何处理 timeout 结果。当约定的 timeout 行为已实现,并且示例或适当的测试证明 listener 可以处理 timeout 时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
I think, though being not sure, that the timeout in Notifier does not work as expected.
From the definition of BusABC.recv(timeout) in here on timeout it returns None that is currently being discarded in Notifier._rx_thread as defined here.
To Reproduce
import time
import can
class MyListener(can.Listener):
def on_message_received(self, msg: can.Message) -> None:
if msg is None:
print("Timeout occurred.")
else:
print(f'Message received: {msg}')
def main():
with can.Bus(interface="virtual", receive_own_messages=True) as bus:
print_listener = MyListener()
notifier = can.Notifier(bus, [print_listener], timeout=1.0)
time.sleep(2.0)
bus.send(can.Message(arbitration_id=1, is_extended_id=False))
notifier.stop()
if __name__ == "__main__":
main()
Expected behaviour
I expect Listener to call "Timeout occurred." in the provided example.
Currently on_message_received is not called on timeout.
I would welcome discussion and help about how to realize timeout behaviour in Listener - Notifier architecture. I think there should be a way to let Listeners handle being starved.
- 主要语言
- Python
- 星标
- 1.6k
- 派生
- 697
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hardbyte/python-can 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
hardbyte/python-can#2103 ·
-
bug
难度 1/5 1 小时以内 新手友好度 78/100
hardbyte/python-can#2077 · 1 条评论 · 1 个 reaction ·
-
bug
难度 1/5 1 小时以内 新手友好度 68/100
hardbyte/python-can#1922 · 1 个 reaction ·
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
hardbyte/python-can#2102 ·
-
bug
难度 3/5 1-2 天 新手友好度 68/100
hardbyte/python-can#2092 ·
查看 hardbyte/python-can 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·