Repository navigation
fix: transitive dependency conflict with Klyne - #25
Merged
psincraian merged 1 commit intoNov 19, 2025
Merged
psincraian merged 1 commit into
psincraian merged 1 commit into
Conversation
Fixed dependency conflict where library A could not use Klyne if its
dependency (library B) already used Klyne. The SDK now supports multiple
concurrent clients in the same Python process.
## Changes
**Architecture:**
- Replaced single global `_client` with `_clients` dictionary (keyed by project name)
- Added `_default_client` for backward compatibility with module-level API
- Each project gets its own isolated KlyneClient instance
**API Enhancements:**
- `init()` now returns KlyneClient instance for direct use
- Module-level functions (track, flush, etc.) still work for backward compatibility
- Libraries can use either module-level API or instance-based API
**Auto-initialization:**
- Removed automatic self-analytics initialization on import
- Self-analytics now opt-in via KLYNE_SELF_ANALYTICS=1 environment variable
- Prevents unwanted side effects and background threads on import
## Testing
- All existing integration tests pass (backward compatibility verified)
- Added comprehensive test suite in test_multiple_clients.py
- Tested nested library scenario (Library A depends on Library B)
## Breaking Changes
None - fully backward compatible. Existing code continues to work unchanged.
## Migration Guide
For libraries that want isolation from other Klyne users:
```python
# Old style (still works)
import klyne
klyne.init(api_key="...", project="my-lib")
klyne.track("event")
# New style (recommended for libraries)
import klyne
client = klyne.init(api_key="...", project="my-lib")
client.track("event")
```
Fixes issue where only one library per process could use Klyne analytics.
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.
Fixed dependency conflict where library A could not use Klyne if its dependency (library B) already used Klyne. The SDK now supports multiple concurrent clients in the same Python process.
Changes
Architecture:
_clientwith_clientsdictionary (keyed by project name)_default_clientfor backward compatibility with module-level APIAPI Enhancements:
init()now returns KlyneClient instance for direct useAuto-initialization:
Testing
Breaking Changes
None - fully backward compatible. Existing code continues to work unchanged.
Migration Guide
For libraries that want isolation from other Klyne users:
Fixes issue where only one library per process could use Klyne analytics.