Handle MemoryError in aioble_central.py scanner event
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 30/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- embedded-iot
Rechercherichtung
Beginne in aioble_central.py beim _IRQ_SCAN_RESULT-Handler und verfolge, wie _active_scanner, queue_scan und das Scanner-Ereignis nach einem MemoryError verwaltet werden. Reproduziere die bereitgestellte Scan-Konfiguration und überprüfe, ob sich das Scannen erholen kann und ScanResult-Objekte wieder erstellt werden, ohne dass der Zustand der Queue oder des Ereignisses inkonsistent bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 2.9k
- Forks
- 1.1k
- Ø Merge
- 4 Std. 17 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus micropython/micropython-lib
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
micropython/micropython-lib#943 · 1 Kommentar ·
-
"requests" does not handle redirection with relative path correctlyEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
micropython/micropython-lib#931 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
micropython/micropython-lib#795 · 2 Kommentare ·
-
webrepl: Support LAN as well as WLAN boards.Evtl. vergeben @Romaric-RILLET hat das vor 788 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
micropython/micropython-lib#762 ·
Alle Issues in micropython/micropython-lib
Ähnliche Issues
-
New InternshipOffennew_internship
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
get_graph warns that the oneway column is missing when no way has a oneway tagEvtl. vergeben @HTenkanen hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
cython/cython#8110 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
fix: security 🔐 style: article/section 📝 system: data-mgmt 🗃️ system: security 🔐 system: software 💻
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
uabrc/uabrc.github.io#1267 ·
-
Link Checker ReportOffenBot Type: Bug Type: Documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag