Repository navigation
Commit 1de0a11
fix(socket_mode): shut down current_session_runner in built-in close()
The built-in SocketModeClient starts three IntervalRunner daemon threads
in __init__ (current_session_runner, current_app_monitor, message_processor)
but close() only shut down two of them, leaking current_session_runner on
every closed instance. Long-lived processes that open and close many clients
accumulate one idle thread per closed instance (issue #1873).
The sync sibling websocket_client.close() already shuts its
current_session_runner down, and the async backends cancel all their futures.
The leak was built-in only.
Adding the shutdown alone is not enough: current_session_runner runs
run_until_completion, whose loop exits only when the connection state is
terminated. disconnect() does not set that flag, and shutdown() joins with no
timeout, so the join would hang on a connected client. close() now sets
current_session_state.terminated = True before disconnecting (mirroring
connect()'s handling of a retired session), letting the loop return so the
join completes. This is the CI hang the earlier #1874 attempt ran into.
Adds a regression test on the connected path (connect then close) asserting
all three runners are reaped; it hangs under pytest-timeout if terminated is
not set, so it guards both the leak and the deadlock.
Refs #1873. Supersedes #1874.
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>1 parent c30a05d commit 1de0a11
2 files changed
Lines changed: 29 additions & 1 deletion
File tree
- slack_sdk/socket_mode/builtin
- tests/slack_sdk/socket_mode
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
227 | 228 | | |
| 229 | + | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
0 commit comments