0.8.0
What's Changed
- Improved Meshtastic connection handling by @jeremiah-k in #76
New Features & Bugfixes
Graceful Shutdown Handling
Signal Handling for SIGINT and SIGTERM:
- The application now properly handles shutdown signals (Ctrl+C or termination signals) to ensure a clean and graceful shutdown process.
- Signal handlers are set up to capture SIGINT and SIGTERM, triggering the shutdown procedure without abrupt termination.
Shutdown Event and Task Cancellation:
- Introduced an
asyncio.Event
(shutdown_event
) to manage the shutdown process asynchronously. - All running tasks are properly canceled during shutdown to prevent resource leaks or incomplete operations.
- Ensures that connections to Matrix and Meshtastic are closed gracefully.
Robust Meshtastic Reconnection Logic
Automatic Reconnection on Device Reboot or Disconnection:
- The application now detects when the Meshtastic device is disconnected (e.g., due to a remote reboot command) and attempts to reconnect automatically.
- Implemented exponential backoff for reconnection attempts, starting from 10 seconds and capping at 5 minutes.
Thread-Safe Reconnection Handling:
- Utilized threading locks (
meshtastic_lock
) to prevent race conditions and ensure thread safety during reconnection attempts. - Introduced flags (
reconnecting
andshutting_down
) to manage the reconnection state and prevent overlapping reconnection attempts.
Enhanced Error Handling and Logging
Specific Exception Handling:
- Added exception handling for
OSError
witherrno 9
(Bad file descriptor) to avoid unnecessary warnings when closing already closed connections. - Handled exceptions during client closure and reconnection to prevent crashes and provide informative logs.
Informative Logging Statements:
- Improved logging throughout the application to provide clear insights into the application's state and actions.
- Logs include connection attempts, reconnection successes or failures, and shutdown processes.
Please test and report any issues.
Full Changelog: 0.7.0...0.8.0