micropython / micropython/micropython-lib

aioble: Unhandled exception in IRC callback - memory allocation failed

Aperta
#982 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
2.9k
Fork
1.1k
Merge medio
7g 6h
PR unite (30g)
3

Descrizione

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....

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da core.py riga 71 e central.py riga 61, il percorso del callback IRQ mostrato nel traceback. Esegui il carico di lavoro aioble.scan di lunga durata insieme alle altre attività e osserva come MemoryError influisce sull'attività di scansione. Il lavoro è completato quando il comportamento desiderato in caso di errore di allocazione è definito e verificato senza interrompere silenziosamente la scansione in background.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
embedded-iot
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.