Handle MemoryError in aioble_central.py scanner event
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- embedded-iot
Direzione di ricerca
Inizia in aioble_central.py dal gestore _IRQ_SCAN_RESULT e traccia come vengono gestiti _active_scanner, queue_scan e l’evento dello scanner dopo un MemoryError. Riproduci la configurazione di scansione fornita e verifica se la scansione può riprendersi e se gli oggetti ScanResult ricominciano a essere creati senza lasciare incoerente lo stato della coda o dell’evento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 2.9k
- Fork
- 1.1k
- Merge medio
- 4h 17m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
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.
Altre issue di micropython/micropython-lib
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
micropython/micropython-lib#943 · 1 commento ·
-
"requests" does not handle redirection with relative path correctlyForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
micropython/micropython-lib#931 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
micropython/micropython-lib#795 · 2 commenti ·
-
webrepl: Support LAN as well as WLAN boards.Forse già presa @Romaric-RILLET l’ha presa 788 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
micropython/micropython-lib#762 ·
Tutte le issue di micropython/micropython-lib
Issue simili
-
Import errors are swallowed: PerthImplicitWatermarker silently becomes NoneForse già presa @JonRC l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
resemble-ai/Perth#23 ·
-
correction metadata
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 65/100
acl-org/acl-anthology#10753 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
earthtojake/text-to-cad#758 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 70/100
DataTalksClub/faq#545 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno