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.
Add Kernel-Level AI Features (Tier 1) #224
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
Uh oh!
There was an error while loading. Please reload this page.
Add Kernel-Level AI Features (Tier 1) #224
Changes from all commits
5dc1038File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Check warning on line 39 in cortex/kernel_features/accelerator_limits.py
Replace the type hint "list[int]" with "Optional[list[int]]" or don't assign "None" to "gpu_ids"
Check failure on line 80 in cortex/kernel_features/kv_cache_manager.py
Specify an exception class to catch or reraise the exception
Check failure on line 93 in cortex/kernel_features/kv_cache_manager.py
Specify an exception class to catch or reraise the exception
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.
Replace bare
exceptclauses with specific exception types.Bare
except:catches all exceptions includingKeyboardInterruptandSystemExit, which can mask critical errors. The static analysis tools flag this as a failure.class SharedMemoryPool: def __init__(self, name: str, size: int, create: bool = True): self.name = f"{SHM_PREFIX}{name}" self.size = size if create: try: old = shared_memory.SharedMemory(name=self.name) old.close() old.unlink() - except: + except FileNotFoundError: pass self.shm = shared_memory.SharedMemory(name=self.name, create=True, size=size + 8192) else: self.shm = shared_memory.SharedMemory(name=self.name) def get_usage(self): return self.size, 0, 0 # Simplified def destroy(self): self.shm.close() try: self.shm.unlink() - except: + except FileNotFoundError: pass📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis
[failure] 93-93: Specify an exception class to catch or reraise the exception
See more on https://sonarcloud.io/project/issues?id=cortexlinux_cortex&issues=AZretQP9i-4iu7DOY4jn&open=AZretQP9i-4iu7DOY4jn&pullRequest=224
[failure] 80-80: Specify an exception class to catch or reraise the exception
See more on https://sonarcloud.io/project/issues?id=cortexlinux_cortex&issues=AZretQP9i-4iu7DOY4jm&open=AZretQP9i-4iu7DOY4jm&pullRequest=224
🪛 Ruff (0.14.7)
80-80: Do not use bare
except(E722)
80-81:
try-except-passdetected, consider logging the exception(S110)
93-93: Do not use bare
except(E722)
93-94:
try-except-passdetected, consider logging the exception(S110)
🤖 Prompt for AI Agents
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.
Resource leak: shared memory not cleaned up if pool not in current instance.
If a pool was created by a different process instance, it won't be in
self.pools. The method deletes the DB record but leaves the shared memory segment orphaned.def destroy_pool(self, name: str) -> bool: if name in self.pools: self.pools[name].destroy() del self.pools[name] + else: + # Try to clean up SHM created by another process + try: + pool = SharedMemoryPool(name, 0, create=False) + pool.destroy() + except FileNotFoundError: + pass with sqlite3.connect(CORTEX_DB) as conn: conn.execute("DELETE FROM pools WHERE name=?", (name,)) print(f"✅ Destroyed pool '{name}'") return TrueUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.