Skip to content

feat: module level singleton pattern For Pulse instantiation #20

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

Merged
merged 3 commits into from
May 30, 2025

Conversation

aanshu-ss
Copy link
Collaborator

@aanshu-ss aanshu-ss commented May 29, 2025

Background: If Pulse object is initialized twice it gives us a warning like this:
Overriding of current LoggerProvider is not allowed"

We want the Pulse SDK to be initialized only once per kernel, so that any notebook connected to a kernel has access to a singleton pulse object. This works as expected when a new kernel is started.
However, issues arise when the feature flag (FF) is changed and the notebook page is reloaded. In some cases, the reload starts a new kernel (which is fine), but other times it reconnects to an existing idle kernel. If that kernel was initialized before the FF change, it may not have the correct pulse object, leading to inconsistent behavior.
Since we rely on having a single, correctly-initialized pulse instance per kernel, we need to address this.

Hence, we use module level singleton pattern for Pulse class. where the global state is maintained at the module level.

Testing

Tested locally and test case updated.Pulse is instantiated before also, and when we re-instantiate it again, it skips the reinstantiation with message: Pulse instance already exists. Skipping initialization.
Screenshot from 2025-05-30 18-26-59

JIRA

https://memsql.atlassian.net/browse/MCDB-74788

@aanshu-ss aanshu-ss merged commit 5e05ab2 into master May 30, 2025
@aanshu-ss aanshu-ss deleted the aanshu/fix-multiple-initialization branch May 30, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants