FeishuChannel.stop leaves bot identity retry task pending
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
lark_oapi.channel.channel の _start_bot_identity_retry_loop()、schedule()、stop() から始めます。長い遅延の retry を再現し、その後、stop() が retry future をキャンセルして消化し、pending-task 警告が発生しないことを検証するライフサイクル回帰テストを追加します。完了条件は、bot-identity retry が channel によって追跡され、シャットダウン時に保留中のタスクが残らないことです。
索引モデルが issue の本文から書いたものです。
説明
Affected version
lark-oapi1.7.3- Default branch commit:
0b9e6e48b74bb4b34462fc67b7e738b27e73e697 - Reproduced on Python 3.13.13 and 3.14.4 on Windows
Problem
FeishuChannel._start_bot_identity_retry_loop() submits _bot_identity_retry_loop() with asyncio.run_coroutine_threadsafe() but discards the returned future. Unlike FeishuChannel.schedule(), this path never adds the future to _bg_tasks.
FeishuChannel.stop() only cancels futures in _bg_tasks before stopping and closing the background event loop. A sleeping bot-identity retry therefore survives shutdown as a pending task.
Minimal reproduction
import asyncio
import time
from unittest.mock import patch
from lark_oapi.channel import FeishuChannel
channel = FeishuChannel(app_id="cli_x", app_secret="s")
channel._ensure_bg_loop()
channel._BOT_IDENTITY_RETRY_DELAYS_S = (3600,)
captured = []
original = asyncio.run_coroutine_threadsafe
def capture(coro, loop):
future = original(coro, loop)
captured.append(future)
return future
with patch(
"lark_oapi.channel.channel.asyncio.run_coroutine_threadsafe",
side_effect=capture,
):
channel._start_bot_identity_retry_loop()
time.sleep(0.05)
print(captured[0] in channel._bg_tasks) # False
channel.stop()
print(captured[0].done(), captured[0].cancelled()) # False False
At interpreter shutdown:
Task was destroyed but it is pending!
task: <Task pending ... coro=<FeishuChannel._bot_identity_retry_loop() ...>>
The same pending-task warning appeared after the native test suite on both Python 3.13 and 3.14.
Expected behavior
stop() should cancel and drain every task owned by the channel background loop, including the bot-identity retry task, without a pending-task warning.
Impact
A startup identity lookup failure schedules a retry that can sleep for up to an hour. Stopping or reconnecting the channel during that delay closes its loop while the retry is still pending. This produces noisy shutdown diagnostics and leaves channel-owned work outside the documented lifecycle tracking.
Suggested implementation
Route this coroutine through the existing schedule() helper, or explicitly track its future in _bg_tasks, then add a lifecycle regression test that starts a long-delay retry, calls stop(), and verifies the future is cancelled and no pending task remains.
I searched open and closed issues, all pull request states, and repository history for bot identity retry, Task was destroyed, _start_bot_identity_retry_loop, and related lifecycle terms. I did not find an existing report or competing fix. Open PRs #139, #144, and #151 touch adjacent client/channel lifecycle code but do not track or cancel this retry future.
- 主要言語
- Python
- スター
- 559
- フォーク
- 102
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
larksuite/oapi-sdk-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
larksuite/oapi-sdk-python#163 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
larksuite/oapi-sdk-python#162 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
larksuite/oapi-sdk-python#161 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
larksuite/oapi-sdk-python#160 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
larksuite/oapi-sdk-python#145 ·
larksuite/oapi-sdk-python の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
zostera/django-bootstrap4#894 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
use-agent-os/agent-os#3276 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#117848 ·