Fix None issue in reorganizer queue#125
Merged
CaralHsi merged 2 commits intoMemTensor:devfrom Jul 19, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a None-handling issue in the reorganizer queue by replacing the use of None as a sentinel value with a proper "end" operation type. The change improves type safety and makes the queue termination mechanism more explicit.
- Introduces a new "end" operation type to the QueueMessage class
- Replaces None sentinel value with QueueMessage(op="end") for queue termination
- Improves null safety in message preprocessing by adding additional None checks
| import time | ||
| import traceback | ||
|
|
||
| from collections import Counter, defaultdict |
There was a problem hiding this comment.
The import statement for 'collections' has been moved to the top but the old import on line 9 wasn't removed, creating a duplicate import. Remove the duplicate import statement.
|
|
||
| def __lt__(self, other: "QueueMessage") -> bool: | ||
| op_priority = {"add": 2, "remove": 2, "merge": 1} | ||
| op_priority = {"add": 2, "remove": 2, "merge": 1, "end": 0} |
There was a problem hiding this comment.
The op_priority dictionary is missing the 'update' operation which is defined in the Literal type. This will cause a KeyError when comparing QueueMessage objects with op='update'.
Suggested change
| op_priority = {"add": 2, "remove": 2, "merge": 1, "end": 0} | |
| op_priority = {"add": 2, "remove": 2, "merge": 1, "update": 1, "end": 0} |
Nyakult
approved these changes
Jul 18, 2025
tianxing02
pushed a commit
to tianxing02/MemOS
that referenced
this pull request
Feb 24, 2026
fix: revise None type in QueueMessage to op=end Co-authored-by: CaralHsi <caralhsi@gmail.com>
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.
Description
Summary: (summary)
fix the None type in minheap of reorganizer.
Reviewer: @CaralHsi
Checklist: