Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

SocketcanBus.send() timeout semantics differ from BusABC.send()

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
linux, python

調査の方向性

まず SocketcanBus.send() の実装を BusABC.send() のドキュメントおよび動作と比較し、次に、提供された送信ループで説明されているキュー満杯のケースを再現します。タイムアウトが指定されていない場合にドキュメント化されたブロッキングセマンティクスに従い、明示的なタイムアウトでは記載された動作が維持されれば完了です。既存のテスト箇所が見つかった場合は、これらのケースのカバレッジを追加または更新してください。

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

説明

bug
Describe the bug

In the send() method of BusABC, the optional timeout argument is documented as

If > 0, wait up to this many seconds for message to be ACK'ed or
for transmit queue to be ready depending on driver implementation.
If timeout is exceeded, an exception will be raised.
Might not be supported by all interfaces.
None blocks indefinitely.

but the SocketcanBus implementation of BusABC documents (and implements) it like this:

Wait up to this many seconds for the transmit queue to be ready.
If not given, the call may fail immediately.

It looks to me like the handling in SocketcanBus just doesn't conform to the expected interface, in particular it does

# If no timeout is given, poll for availability
if timeout is None:
    timeout = 0

which results in nonblocking behavior and potentially raising can.CanOperationError("Transmit buffer full") instead of waiting indefinitely when no timeout is specified.

To Reproduce
msg = can.Message(
    arbitration_id=0x123, is_extended_id=False, data=[1, 2, 3, 4, 5, 6, 7, 8]
)
with can.Bus(interface="socketcan", channel="can0") as bus:
    for i in range(10000):
        bus.send(msg)

Observe that sending fails if the sending rate exceeds the capacity of the bus, instead of blocking and waiting.

Expected behavior

As the timeout is None, blocking indefinitely until the transmit queue is ready, as specified in the BusABC.send() docs.

Additional context

OS and version: Ubuntu 24.04.3 LTS, 6.14.0-35-generic
Python version: Python 3.12.3
python-can version: 4.3.1
python-can interface/s (if applicable): socketcan, F81601 interface (PCI), Manufacturer provided driver

主要言語
Python
スター
1.6k
フォーク
697
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

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

hardbyte/python-can のほかの issue

hardbyte/python-can の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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