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
-
URLValidator ignores an explicit empty scheme allowlist可能已有人在做 @IlyaKhalafi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 85/100
tortoise/tortoise-orm#2393 ·
維護者通常 2 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 62/100
frappe/frappe_docker#2046 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
-
AXI SMU SPEC
難度 2/5 1-3 小時 新手友好度 62/100
tenstorrent/tt-oca-harness#3556 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
microsoft/agent-framework#9946 ·
維護者通常 1 天內回覆