-
Notifications
You must be signed in to change notification settings - Fork 30
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
timeout height task should be canceled after deleting client #360
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe changes introduce a destructor method Changes
Sequence Diagram(s)sequenceDiagram
participant Client as AsyncClient
participant Task as Timeout Height Sync Task
Client->>Task: Start synchronization task
Client->>Client: Instance is deleted
Client->>Task: Call __del__()
Task-->>Client: Cancel synchronization task
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
pyinjective/async_client.py (1)
3466-3467
: LGTM! The destructor ensures proper cleanup of the timeout height task.The implementation correctly cancels the timeout height synchronization task when the
AsyncClient
instance is deleted, preventing potential memory leaks. The code reuses the existing_cancel_timeout_height_sync_task()
method which safely handles the cleanup.Consider adding a debug log statement to help with troubleshooting:
def __del__(self): + LoggerProvider().logger_for_class(logging_class=self.__class__).debug("Cleaning up AsyncClient instance") self._cancel_timeout_height_sync_task()
In case you should re initialize your injective async client multiple times, deleting the client won't stop sync timeout height task and it may increase the risk of memory leakage in the main program.
This two line makes sure when the client is no longer used, the timeout syncing will be stopped.
Summary by CodeRabbit
AsyncClient
instance is deleted, preventing potential memory leaks.