Skip to content

Conversation

pkusnail
Copy link

@pkusnail pkusnail commented Sep 25, 2025

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Please describe your changes here. If this fixes a bug, please link to the issue, if possible.
This feature is essential for this PR langflow-ai/langflow#9982

- Add __getstate__ and __setstate__ methods to ConsoleThreadLocals class
- Add __getstate__ and __setstate__ methods to Console class
- Enable serialization for caching frameworks like Redis
- Maintains backward compatibility and thread safety
- Fixes 'cannot pickle ConsoleThreadLocals object' error
- Add test_pickle_support.py with 5 comprehensive test cases
- Test ConsoleThreadLocals and Console pickle functionality
- Test cache simulation scenario (Langflow compatibility)
- Test complex state preservation and nested objects
- All tests pass and verify proper serialization/deserialization
- Add test_pickle_fix.py for manual testing and validation
- Tests basic functionality, Langflow compatibility, and thread-local behavior
- Provides detailed output for debugging and verification
- Can be run independently for quick validation
- Add entry under [Unreleased] section for pickle support feature
- Reference PR Textualize#3853 for ConsoleThreadLocals and Console serialization
- Follows Keep a Changelog format
- Add Tony Seah (pkusnail) to contributors list for pickle support contribution
- Alphabetically placed for proper organization
- Format rich/console.py with black for consistency
- Format tests/test_pickle_support.py and test_pickle_fix.py
- Ensures code style compliance with Rich project standards
@willmcgugan
Copy link
Member

Pickling Console objects doesn't make a great deal of sense. This feels like a workaround that likely has a better solution.

I would need confirmation from the Langflow devs before I merge this one.

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.

2 participants