Add param to enable "Auto-Acknowledgment" of Events to the SocketModeClient
まだ誰も着手していません。
評価
調査の方向性
まず、issue に記載されている SocketModeClient enqueue_message のフローと async socket client のセットアップから始めます。キューに入れられた burst イベントがどのように acknowledgement を受け取るかを追跡し、続いて、listener が処理を継続し、socket 接続が開いたままの状態で、メッセージが必要な期間内に acknowledgement されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
One issue we have noticed in our deployment of a Slack app is that when there are a burst of messages being received, the built-in queue can become too large and can cause messages to expire within the 3-5 second acknowledgment period.
For example, our app receives 200 messages within a 5 second window. They are then received and queued for the message listeners to process. If the queue gets too large, it may take longer than 3-5 seconds for a listener to dequeue and process a message. This results in the app being restricted and unable to receive new messages. This can get exponentially worse when the burst is followed up by a burst of retry messages as well.
Reproducible in:
The Slack SDK version
slack-sdk==3.19.2
Python runtime version
Python 3.10.5
OS info
ProductName: macOS
ProductVersion: 11.5.2
BuildVersion: 20G95
Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
Steps to reproduce:
(Share the commands to run, source code, and project settings (e.g., setup.py))
- Setup async socket client
- Append one listener
- Receive burst of events
Expected result:
So the thought was to set a parameter which would allow messages to be auto-acknowledged as they enter the queue. This would allow the listeners to handle the events irrespective of their processing time.
It could work something like this:
async def enqueue_message(self, message: str):
await self.message_queue.put(message)
if self.auto_acknowledge_messages:
await self.auto_acknowledge_message(raw_message=message)
if self.logger.level <= logging.DEBUG:
queue_size = self.message_queue.qsize()
session_id = await self.session_id()
self.logger.debug(f"A new message enqueued (current queue size: {queue_size}, session: {session_id})")
async def auto_acknowledge_message(self, raw_message):
if raw_message.startswith("{"):
message = json.loads(raw_message)
if message.envelope_id:
response = SocketModeResponse(envelope_id=message.envelope_id)
await self.send_socket_mode_response(response)
Actual result:
Socket connection is closed due to missing too many acknowledgements.
Requirements
For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
- 主要言語
- Python
- スター
- 4k
- フォーク
- 857
- 平均マージ
- 22時間 21分
- マージ済み PR(30日)
- 16
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
slackapi/python-slack-sdk のほかの issue
-
needs info server-side-issue
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
slackapi/python-slack-sdk#1961 · コメント 3 件 ·
-
Use logger.isEnabledFor(logging.DEBUG) instead of logger.level <= logging.DEBUG for debug guards オープンauto-triage-skip bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
slackapi/python-slack-sdk#1957 ·
-
auto-triage-skip discussion
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
slackapi/python-slack-sdk#1940 · コメント 2 件 ·
-
chat_postMessage silently forwards thread_id to the API, so a threaded reply posts to the channel オープンauto-triage-skip enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
slackapi/python-slack-sdk#1923 · コメント 2 件 ·
-
auto-triage-skip bug socket-mode
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
slackapi/python-slack-sdk#1922 · コメント 2 件 ·
slackapi/python-slack-sdk の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
huggingface/Repo2RLEnv#163 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
NousResearch/hermes-agent#121143 ·