fix(dingtalk): support dingtalk-stream >= 0.20 async API and fix timeout#10153
Closed
gundamff wants to merge 1 commit into
Closed
fix(dingtalk): support dingtalk-stream >= 0.20 async API and fix timeout#10153gundamff wants to merge 1 commit into
gundamff wants to merge 1 commit into
Conversation
- Add SDK version detection for async/sync method compatibility using inspect.iscoroutinefunction() - Fix webhook URL regex to support both api.dingtalk.com and oapi.dingtalk.com - Parse CallbackMessage.data dict for SDK >= 0.20 compatibility - Process messages in background thread to avoid blocking dingtalk-stream - Increase timeout from 60s to 300s for AI response handling Fixes timeout errors and improves response speed for DingTalk bot with SDK >= 0.20.
REVIEW SUMMARYAPPROVE with minor suggestions. CHANGES VERIFIED
SECURITY CHECKLIST
QUALITY OBSERVATIONSGOOD:
SUGGESTIONS:
# In __init__
self._thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10)
# In _dispatch_message
def handle_message(): ...
self._thread_pool.submit(handle_message)
# Consider threading.Lock for eviction or use dict pop with sentinel
with self._webhook_lock:
if len(self._session_webhooks) >= _SESSION_WEBHOOKS_MAX:
self._session_webhooks.pop(next(iter(self._session_webhooks)))
NITPICKS
TESTINGExisting tests pass. Recommend adding test for Overall solid fix for dingtalk-stream compatibility issues. |
Contributor
|
Closing as superseded by #11471 (#11471) which salvaged @kevinskysunny's minimal fix (#11257) and added a follow-up for the broken Thanks for the fix — a lot of contributors hit this SDK break at the same time. Your investigation helped confirm the root cause. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes DingTalk adapter compatibility with dingtalk-stream SDK >= 0.20 and resolves timeout issues.
Changes
inspect.iscoroutinefunction()api.dingtalk.comandoapi.dingtalk.comin regexCallbackMessage.datadict for SDK >= 0.20Testing
Tested with:
Related Issues
Fixes slow response and timeout errors in DingTalk bot.