-
Notifications
You must be signed in to change notification settings - Fork 4
Fix/telegram polling stability #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The Telegram polling thread would silently crash due to network timeouts or other exceptions, causing callback buttons (Approve/Reject) to stop working while the scheduled auto-approval continued functioning normally. Changes: - Replace bot.polling(none_stop=True) with bot.infinity_polling() - Add run_telegram_polling() wrapper with automatic restart on failure - Log and notify when polling restarts to aid debugging - Set thread as daemon for clean shutdown - Configure appropriate timeout values (60s connection, 30s long_polling) This ensures the polling thread recovers from transient failures instead of dying silently.
Translate inline comments in calculate_transaction_size() for consistency.
Summary of ChangesHello @TrezorHannes, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the stability and reliability of the Telegram bot's interaction capabilities. By addressing a critical issue where the polling thread could silently die, leading to unresponsive callback buttons, the changes ensure that the bot consistently processes user input. The new robust polling mechanism, complete with automatic restarts and error notifications, guarantees continuous operation and a much improved user experience without requiring manual intervention. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses the silent failure of the Telegram polling thread by replacing bot.polling with the more robust bot.infinity_polling within a restart wrapper. This is a great improvement for the stability of the bot. The translation of comments also improves code clarity. I have a few suggestions to further enhance the robustness and maintainability of the new implementation.
1. Exponential backoff for polling restarts: - Add TELEGRAM_POLL_* constants for configurable backoff - Delay increases 10s -> 20s -> 40s -> ... up to 5 min cap - Resets on successful polling 2. Extract magic numbers to named constants: - P2WPKH_INPUT_VBYTES = 57.5 - P2WPKH_OUTPUT_VBYTES = 43 - TRANSACTION_OVERHEAD_VBYTES = 10.5 3. Move run_telegram_polling() to module level: - Better modularity and testability - No longer nested inside if __name__ == '__main__' Tests: 12/12 passing
PR: Fix Telegram Callback Buttons Not Working
Summary of Changes
Root Cause
The
bot.polling(none_stop=True)thread was silently dying on network timeouts or exceptions. When this happened:Detailed Changes
magma_sale_process.py
Polling fix:
bot.polling(none_stop=True)withbot.infinity_polling()run_telegram_polling()wrapper with automatic restart on failureMinor cleanup:
calculate_transaction_size()Testing Strategy
python3 -m py_compile✅Commits
fix(magma): replace bot.polling() with robust infinity_polling wrapperchore(magma): translate Portuguese comments to EnglishChecklist