-
Notifications
You must be signed in to change notification settings - Fork 22
[LSP] Task execution context vars and cancellation abort checkpoints (CF-766) #849
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
base: main
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
⚡️ Codeflash found optimizations for this PR📄 101% (1.01x) speedup for
|
| class CodeflashServerSingleton: | ||
| _instance: CodeflashLanguageServer | None = None | ||
|
|
||
| @classmethod | ||
| def get(cls) -> CodeflashLanguageServer: | ||
| if cls._instance is None: | ||
| cls._instance = CodeflashLanguageServer( | ||
| "codeflash-language-server", "v1.0", protocol_cls=CodeflashLanguageServerProtocol | ||
| ) | ||
| return cls._instance | ||
|
|
||
| def __init__(self) -> None: | ||
| # This is a singleton class, so we don't want to initialize. | ||
| ... |
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.
just initialize the instance once and keep it around, don't use this pattern as it can cause issues down the line: https://nedbatchelder.com/blog/202204/singleton_is_a_bad_idea.html
PR Type
Enhancement, Bug fix
Description
Introduce singleton LSP server instance
Add per-task execution context vars
Implement cancellation abort checkpoints
Simplify server feature handlers' signatures
Diagram Walkthrough
File Walkthrough
beta.py
Feature handlers refactor with context and cancelcodeflash/lsp/beta.py
CodeflashServerSingletonusage.task_idparam and execution context manager.perform_optimization.py
Add cancellable optimization checkpointscodeflash/lsp/features/perform_optimization.py
lsp_message.py
Propagate task_id in LSP messagescodeflash/lsp/lsp_message.py
task_idfrom execution context in messages.server.py
Server singleton and context vars supportcodeflash/lsp/server.py
CodeflashServerSingleton.execution_context_varscontextvar to server.