Handle MemoryError in aioble_central.py scanner event
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- embedded-iot
调研方向
从 aioble_central.py 中的 _IRQ_SCAN_RESULT 处理程序开始,追踪发生 MemoryError 后 _active_scanner、queue_scan 和扫描器事件是如何管理的。复现所提供的扫描配置,并验证扫描是否能够恢复,以及 ScanResult 对象是否能够继续创建,同时不会使队列或事件状态处于不一致状态。
由索引模型根据 Issue 内容生成。
描述
I am using the scanner as follows in my application code
# The 'scanner' is of type 'scan' defined in aioble
async with scan(duration_ms=10000, # The length of the scan cycle in milliseconds.
interval_us=30000, # The time between each scan listen start
window_us=15000, # The length of time during the scan interval one is actually listening
# If interval_us = window_us the scan is non stop (so called fully duty cycle)
# Background scanning usually sets the window_us to be less than interval_us.
active=True) as scanner: # active = True means do scan requests to get scan responses
# For PHD we always want to do active scans.
However, every once and a while in the scan event handler a MemoryError is thrown while trying to load a result into the queue shown below:
if event == _IRQ_SCAN_RESULT:
addr_type, addr, adv_type, rssi, adv_data = data # data here is a tuple[int, bytes, int, int, bytes]
if not _active_scanner:
return
try:
if queue_scan:
_active_scanner._queue.append((addr_type, bytes(addr), adv_type, rssi, bytes(adv_data)))
_active_scanner._event.set()
except MemoryError:
queue_scan = False
logger.error('LNI: AIOBLE: Memory allocation error queuing an advertisement/scan response.') # type: ignore
import gc
gc.collect()
I have added a handler for the exception and would like to be able to recover from the error but am not sure what else I need to do. With the code shown above, the scanner restarts after 10 seconds but ScanResult objects are no longer created. Not sure why. Do I need to set the event? Do I need to add a filter that blocks repeat advertisements in a given scan cycle? Maybe it is simply not possible to recover from such an error?
Any help is greatly appreciated, especially from the code author.
- 主要语言
- Python
- 星标
- 2.9k
- 派生
- 1.1k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
micropython/micropython-lib 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
micropython/micropython-lib#1074 ·
-
needs-info
难度 1/5 1 小时以内 新手友好度 72/100
micropython/micropython-lib#943 · 1 条评论 ·
-
"requests" does not handle redirection with relative path correctly可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
micropython/micropython-lib#931 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 62/100
micropython/micropython-lib#795 · 2 条评论 ·
-
webrepl: Support LAN as well as WLAN boards.可能已有人在做 @Romaric-RILLET 于 787 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
micropython/micropython-lib#762 ·
查看 micropython/micropython-lib 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
pytest-dev/pyfakefs#1367 · 1 条评论 ·
维护者通常 2 天内回复
-
IFEvalG exclude_word_harder misses the keyword next to punctuation, at the start or end of the text, and in other letter case可能已有人在做 @damienen 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
allenai/open-instruct#2151 ·
维护者通常 1 天内回复
-
feat(plan): support convertorLabels and convertorAffinity in Plan resource可能已有人在做 @AmenB 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
RedHatQE/openshift-python-wrapper#2849 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 25 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
libnativeapi/nativeapi#21 ·