Manage single mongodb connection for bot - #828
Merged
amirbiron merged 2 commits intoOct 17, 2025
Merged
Conversation
This change defers reporter initialization until runtime, preventing multiple MongoDB connections and ensuring proper handling in different environments. Co-authored-by: amirbiron <amirbiron@gmail.com>
Contributor
|
Cursor Agent can help with this pull request. Just |
Contributor
🧯 Dangerous deletes guard reportPolicy: see .cursorrules — dangerous deletions are blocked unless wrapped safely. Summary:
Flagged findings (file:line:snippet): Excluded matches (by path pattern): |
Co-authored-by: amirbiron <amirbiron@gmail.com>
amirbiron
marked this pull request as ready for review
October 17, 2025 01:51
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
11 of 17 tasks
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.
✨ תיאור קצר
תיקון קריסות הבוט הנגרמות מריבוי חיבורי MongoDB שלא נסגרים. השינוי מאחד את כל הגישה ל-MongoClient לחיבור יחיד גלובלי עם סגירה אוטומטית, ומסיר יצירת חיבורים בזמן import.
📦 שינויים עיקריים
פירוט נקודות (רשימת תבליטים):
activity_reporter.py: הוספתget_mongo_client(singleton),close_mongo_clientעםatexit.register, ושימוש בחיבור יחיד עבורSimpleActivityReporter.bot_handlers.py,conversation_handlers.py,refactor_handlers.py: הוסרו קריאות ל-create_reporterבזמן import. הוגדר_NoopReporterופונקצייתset_activity_reporterלהזרקה בזמן ריצה.main.py: יצירת ה-SimpleActivityReporterוהזרקתו למודולים התלויים בו בזמן ריצה (בתוךCodeKeeperBot.__init__), עם תמיכה ב-DISABLE_ACTIVITY_REPORTER. נוספו בדיקותif reporter is not Noneלפני קריאות ל-report_activity.🧪 בדיקות
🧪 בדיקות נדרשות ב‑PR
📝 סוג שינוי
✅ צ'קליסט
🧩 השפעות/סיכונים
🔗 קישורים
🧯 סיכון / החזרה לאחור (Rollback)
Note
Consolidates MongoDB to a single shared client and switches all bot modules to runtime-injected activity reporter with safe no-op fallback.
get_mongo_clientsingleton andclose_mongo_clientwithatexitinactivity_reporter.py; use shared client inSimpleActivityReporter.create_reporterinbot_handlers.py,conversation_handlers.py,refactor_handlers.pywith_NoopReporter+set_activity_reporterinjection points.report_activitycalls with safe guards/try-except.main.py):DISABLE_ACTIVITY_REPORTER) and inject viaset_*_activity_reporterinto dependent modules.Nonechecks before callingreport_activityacross commands/handlers.Written by Cursor Bugbot for commit cd824f3. This will update automatically on new commits. Configure here.