micropython / micropython/micropython-lib

aioble: Unhandled exception in IRC callback - memory allocation failed

オープン
#982 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
2.9k
フォーク
1.1k
平均マージ
7日 6時間
マージ済み PR(30日)
3

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

traceback に示されている IRQ callback の経路である、core.py の 71 行目と central.py の 61 行目から始めます。他のタスクとともに長時間実行する aioble.scan ワークロードを実行し、MemoryError がスキャンタスクにどのような影響を与えるかを確認します。割り当て失敗時に望ましい動作が定義され、バックグラウンドスキャンを暗黙に停止させることなく検証できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
embedded-iot
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。