micropython / micropython/micropython-lib
aioble: Unhandled exception in IRC callback - memory allocation failed
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 2.9k
- Forks
- 1.1k
- Ø Merge
- 7 T. 6 Std.
- Gemergte PRs (30 T.)
- 3
Beschreibung
Hi,
I have a function that scans for advertising data and decode the information (Ruuvi temperature sensors). However, when this runs for a while together with some other tasks, I'm running into a memory issue.
Unhandled exception in IRQ callback handler
Traceback (most recent call last):
File "core.py", line 71, in ble_irq
File "central.py", line 61, in _central_irq
MemoryError: memory allocation failed, allocating 2048 bytes
This will quit my background BLE scanning task which is updating my temperature data. Of course I can watch the task and restart it, but I hope for a better error handling the the aioble library.
It runs fine for quite some time before it giving the error. It's not reproducible - sometimes it occurs after 5 minutes, sometimes it runs 2h without any issues.
I tried running an exception catcher around the can itself:
try:
async with aioble.scan(duration_ms = duration, interval_us=30000, window_us=30000, active = True) as scanner:
self.scanner = scanner
async for result in scanner:
self._handle_advertisement(result)
except Exception as e:
print('!!!!! Exception in aioble scan')
print(e)
But this doesn't help to prevent the error from happing. Of course I could change the code in central.py myself and see if I can catch the error, but I don't want to mess around with it (yet).
I already have another task that is frequently running a gc.collect() and memory shows up with round 32kB.
Thanks....
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit core.py Zeile 71 und central.py Zeile 61, dem im Traceback gezeigten IRQ-Callback-Pfad. Führe die langlebige aioble.scan-Workload zusammen mit den anderen Tasks aus und beobachte, wie sich MemoryError auf den Scan-Task auswirkt. Als abgeschlossen gilt die Aufgabe, wenn das gewünschte Verhalten bei einem Allocationsfehler definiert und verifiziert ist, ohne den Hintergrund-Scan stillschweigend zu stoppen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- embedded-iot
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100