Handle MemoryError in aioble_central.py scanner event
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 30/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- embedded-iot
Piste de recherche
Commencez dans aioble_central.py au niveau du gestionnaire _IRQ_SCAN_RESULT et suivez la manière dont _active_scanner, queue_scan et l’événement du scanner sont gérés après un MemoryError. Reproduisez la configuration de scan fournie et vérifiez si le scan peut reprendre et si des objets ScanResult recommencent à être créés sans laisser l’état de la file d’attente ou de l’événement incohérent.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 2.9k
- Forks
- 1.1k
- Merge moyen
- 4 h 17 min
- PR mergées (30 j)
- 1
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de micropython/micropython-lib
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
micropython/micropython-lib#943 · 1 commentaire ·
-
"requests" does not handle redirection with relative path correctlyPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
micropython/micropython-lib#931 · 1 commentaire ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
micropython/micropython-lib#795 · 2 commentaires ·
-
webrepl: Support LAN as well as WLAN boards.Peut-être pris @Romaric-RILLET l’a pris il y a 788 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
micropython/micropython-lib#762 ·
Toutes les issues de micropython/micropython-lib
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
yt-project/yt#5624 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
NousResearch/hermes-agent#148376 ·
Les mainteneurs répondent en général sous 1 jour
-
Analysis
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
SACGF/variantgrid#2615 ·
Les mainteneurs répondent en général sous 1 jour