MCPcopy Index your code
hub / github.com/dataelement/Clawith / _SerialPatchQueue

Class _SerialPatchQueue

backend/app/api/feishu.py:168–189  ·  view source on GitHub ↗

Serialize patch requests for one Feishu message to prevent out-of-order overwrite.

Source from the content-addressed store, hash-verified

166
167
168class _SerialPatchQueue:
169 """Serialize patch requests for one Feishu message to prevent out-of-order overwrite."""
170
171 def __init__(self):
172 self._tail: asyncio.Task | None = None
173
174 def enqueue(self, job_factory: Callable[[], Awaitable[None]]) -> None:
175 prev = self._tail
176
177 async def _runner():
178 if prev:
179 try:
180 await prev
181 except Exception as e:
182 logger.warning(f"[Feishu] Previous patch job failed before next job: {e}")
183 await job_factory()
184
185 self._tail = asyncio.create_task(_runner())
186
187 async def drain(self) -> None:
188 if self._tail:
189 await self._tail
190
191
192def _build_llm_history_from_chat_messages(history_messages: list) -> list[dict]:

Callers 2

process_feishu_eventFunction · 0.85
_handle_feishu_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected