Destructor for InventorHATMini assumes ioe device created
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- embedded-iot
調査の方向性
Open inventorhatmini/init.py and inspect the constructor around the assignment to ioe and the del method at line 162. Initialize ioe before device setup and ensure the destructor only resets it when it exists. Reproduce the failed device setup if possible and confirm cleanup no longer raises AttributeError.
索引モデルが issue の本文から書いたものです。
説明
When a device handle can't be created (likely due to the io already being in use), the last traceback implies "not found". I've seen this confuse people.
Eg:
Traceback (most recent call last):
File "/home/pi/robot/tests/test_motors.py", line 5, in <module>
board = inventorhatmini.InventorHATMini()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/robotvenv/lib/python3.11/site-packages/inventorhatmini/__init__.py", line 106, in __init__
self._pin_user_sw = gpiodevice.get_pin(self.PI_USER_SW_PIN, "IHM-SW", INPD)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/robotvenv/lib/python3.11/site-packages/gpiodevice/__init__.py", line 163, in get_pin
lines = chip.request_lines(consumer=f"{consumer}-{label}", config={line_offset: settings})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/robotvenv/lib/python3.11/site-packages/gpiod/chip.py", line 331, in request_lines
req_internal = cast(_ext.Chip, self._chip).request_lines(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 16] Device or resource busy
Exception ignored in: <function InventorHATMini.__del__ at 0xf7008118>
Traceback (most recent call last):
File "/home/pi/robotvenv/lib/python3.11/site-packages/inventorhatmini/__init__.py", line 162, in __del__
self.ioe.reset()
^^^^^^^^
AttributeError: 'InventorHATMini' object has no attribute 'ioe'
This is because a failure has occurred before ioe is assigned. It would be more sensible to assign a None to this object until it is ready (in the class constructor), and then have an if guard on https://github.com/pimoroni/inventorhatmini-python/blob/de6f82f3f5dc5b227f8ff396cab1f35bf506b6b6/inventorhatmini/__init__.py#L162.
Eg:
def __del__(self):
if self.ioe:
self.ioe.reset()
It would still fall to the user to make sense of the device busy, but that might hopefully lead them to check for still-running processes.
- 主要言語
- Python
- スター
- 7
- フォーク
- 5
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pimoroni/inventorhatmini-python のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 50/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
pimoroni/inventorhatmini-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
RunestoneInteractive/rs#1661 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
streamlink/streamlink#7192 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws-samples/sample-per-model-bedrock#795 ·
メンテナーはふだん 1 日以内に返信