MCPcopy Index your code
hub / github.com/slackapi/python-slack-sdk / _flush_buffer

Method _flush_buffer

slack_sdk/web/async_chat_stream.py:225–250  ·  view source on GitHub ↗

Flush the internal buffer with chunks by making appropriate API calls.

(self, chunks: Optional[Sequence[Union[Dict, Chunk]]] = None, **kwargs)

Source from the content-addressed store, hash-verified

223 return response
224
225 async def _flush_buffer(self, chunks: Optional[Sequence[Union[Dict, Chunk]]] = None, **kwargs) -> AsyncSlackResponse:
226 """Flush the internal buffer with chunks by making appropriate API calls."""
227 chunks_to_flush: List[Union[Dict, Chunk]] = []
228 if len(self._buffer) != 0:
229 chunks_to_flush.append(MarkdownTextChunk(text=self._buffer))
230 if chunks is not None:
231 chunks_to_flush.extend(chunks)
232 if not self._stream_ts:
233 response = await self._client.chat_startStream(
234 **self._stream_args,
235 token=self._token,
236 **kwargs,
237 chunks=chunks_to_flush,
238 )
239 self._stream_ts = response.get("ts")
240 self._state = "in_progress"
241 else:
242 response = await self._client.chat_appendStream(
243 token=self._token,
244 channel=self._stream_args["channel"],
245 ts=self._stream_ts,
246 **kwargs,
247 chunks=chunks_to_flush,
248 )
249 self._buffer = ""
250 return response

Callers 1

appendMethod · 0.95

Calls 5

MarkdownTextChunkClass · 0.90
appendMethod · 0.45
chat_startStreamMethod · 0.45
getMethod · 0.45
chat_appendStreamMethod · 0.45

Tested by

no test coverage detected