-
Notifications
You must be signed in to change notification settings - Fork 199
Use asyncio #2880
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
Open
+3,646
−2,707
Open
Use asyncio #2880
Changes from 232 commits
Commits
Show all changes
249 commits
Select commit
Hold shift + click to select a range
699dad3
Test both TCP modes
rwols 908c849
Use enum for 'Mode' in server.py
rwols b4f0420
Make init_options optional
rwols 76f3c3f
WIP add asyncio to transports
rwols 45d7ea6
Test both TCP modes
rwols e8fae30
Use enum for 'Mode' in server.py
rwols c511cec
Make init_options optional
rwols 7438d4a
Use StrEnum
rwols 6a104b0
Merge branch 'chore/add-tests' into feat/asyncio
rwols d59bb1c
More work on adding asyncio
rwols c0bea09
Merge branch 'main' into feat/asyncio
rwols c1fc59c
More work towards asyncio
rwols e35b611
Remove accidental merge conflict changes
rwols 6cad098
Remove code in server.py, I really screwed up the merge but will reba…
rwols 1597782
refactor Promise.__await__
rwols cc642f4
Add more comments to _SetTimeoutAsyncExecutor
rwols cea0e99
Rename Session._invoke_views -> Session._invoke_views_async
rwols 3d30ad4
More work towards asyncio
rwols 472705b
debugging sublime_aio.ViewEventListener
rwols ea34714
Merge branch 'main' into feat/asyncio
rwols 069ed50
Fix calls
rwols 776749a
More fix calls
rwols 0227877
More work. Some diagnostics show intermittently. Request logic is not…
rwols 2649a6f
Tweaks to pull diagnostics handling
rwols 54af917
Restore method names
rwols 1a4589c
Forgot import
rwols 900f721
Restore more method names
rwols 35621cf
ResponseException is not needed, we already have Error
rwols dbf4d7d
Merge branch 'main' into feat/asyncio
rwols f3b2f84
More rename reverts
rwols a9c1692
Add more tracing for understanding why requests are not resolving
rwols 7004df5
Start fixing up 'goto' functionality
rwols a876949
Fix:
rwols d27aa93
debugging
rwols 341ff99
We have something working
rwols 4ed4e3f
Start fixing diagnostic errors because diagnostics work
rwols 7aba65e
Remove trace() calls
rwols e3ccba2
Remove trace() calls
rwols c2c2a8c
Remove trace() calls
rwols af561a8
Fixups
rwols 7260c90
Remove trace() calls and fixup type hints
rwols a60ddd2
Reintroduce request_code_actions_async for SessionBuffer
rwols 23210e3
Consolidate sublime_aio & asyncio functions/classes in plugin/core/ai…
rwols 73ed644
get_session_buffer_for_uri -> get_session_buffer_for_uri_async
rwols 6d6e772
Session.session_buffers -> Session.session_buffers_async
rwols a84f3dd
_invoke_views_async -> _invoke_views
rwols f7702c2
Fix notifications being logged twice
rwols bb51929
Fix LspCheckApplicableCommand... I think
rwols 7d58862
Fix errors in WindowManager.start, and allow async version of LspPlug…
rwols e2119a1
Print exceptions from coroutines started from `run_coroutine_threadsafe`
rwols ce27231
Ensure plugin_unloaded works as expected
rwols a4aba53
Merge branch 'main' into feat/asyncio
rwols c215234
Fixup incorrect (old) usage of Session.send_request_async
rwols ae081e3
Remove trace() calls from sessions.py
rwols e4d3324
Merge branch 'main' into feat/asyncio
rwols 6e5ca85
Fix type errors in sessions.py
rwols 4866feb
Review all sublime.set_timeout_async call sites
rwols 73a658a
Merge branch 'main' into feat/asyncio
rwols 8a6de63
asyncio.Future, async functions, and Promises are all just Awaitables
rwols fcb8717
Fix process args
rwols 8997d51
Fix most type errors, except for tooling.py
rwols 5943571
Fix: document link was requested before didOpen
rwols 7485b90
Rename Files: open files sequentially, as it as before
rwols edd3ccd
apply_text_edits: wait at least one UI frame
rwols 91af0e0
LspPlugin.prefer_async_on_pre_start -> LspPlugin.use_asyncio
rwols da1fc1d
Invoke LspPlugin.on_initialize after the `initialized` notification
rwols 34697be
Update tooling.py for asyncio
rwols aa37898
Remove unused imports
rwols 9335c7d
Fix 'TCP client' mode
rwols afde9fb
Compatibility with python 3.8
rwols 0795ee4
Fix missing import for type checking
rwols 4659e8d
Add stubs/sublime_aio.pyi
rwols 76aeba1
Fix formatting
rwols 66bd43a
Fix all remaining lint errors
rwols a143bdf
Fix interface method (why isn't this reported as an error by either p…
rwols 69fd44d
Fixup interface method of `Manager` (why isn't this reported by eithe…
rwols c2a9e30
Fixup wm.handle_show_message: it's not async
rwols 8835214
Add @override to all methods in WindowManager that implement an inter…
rwols 668846c
Turn off @deprecation warnings
rwols c6a89b1
Fix lint warnings
rwols 9d8c1b3
The return type of the `Window.handle_show_message` interface method …
rwols d271624
Fix reference to task object
rwols 68b8945
Add function: exceptions_log
rwols a3c88ec
Catch possible exception when draining the stream writer
rwols 3915ca6
Add functions aclosing, gather_and_flatten_exceptions, TaskContainer.…
rwols 82973a5
Fix for python 3.8 runtime regarding opening files lock
rwols 1ae40fe
Fixes for python 3.8 runtime, better CancellableInflightStreamingRequ…
rwols 45bbb05
Fix LSP: Rename
rwols 998ac1c
Comment out the debug print in the tranports.py because I'm feeling c…
rwols 9c761d1
Merge branch 'main' into feat/asyncio
rwols 056359b
LspPlugin.use_asyncio() -> LspPlugin.use_asyncio
rwols aca3b34
Fixup incorrect merge resolution in api.py
rwols 1a6448b
I don't know how this got here.
rwols dd2b791
Odds and ends in sessions.py
rwols ff9cfd7
Odds and ends: make `@requires_session` compatible with coroutine fun…
rwols 5e3af9c
WIP refactor tests
rwols d91eeda
Convert unit/integration tests to asyncio
rwols 8676dc4
Fix bugs revealed by tests
rwols c6efba4
Merge branch 'main' into feat/asyncio
rwols 2c2e7b3
Merge branch 'main' into feat/asyncio
rwols 119fa99
Add runtime check for accidental coroutine continuations
rwols 9e35cc4
In the process of fixing bugs due to tests revealing bugs
rwols 8c83c96
Re-introduce classSetUp and classTearDown
rwols 691d8ea
Fixes for macOS
rwols 0aa553b
Merge branch 'main' into feat/asyncio
rwols e9d65dd
Fixes after merge
rwols a8f6ba1
Merge branch 'main' into feat/asyncio
rwols a5d67f5
Session.open_scratch_buffer always returns a View
rwols 09b3d3d
Fix disabling and then enabling configs
rwols bc70dee
Simplify executors, and encode/decode JSON on the ST async thread
rwols 7005ac0
Maybe fix LSP.tests.test_single_document.SingleDocumentTestCase.test_…
rwols 750b995
Remove debug prints from test code
rwols e3fc6e9
Fix remaining tests... hopefully?
rwols 6817036
Fix lint errors
rwols 3c90ff9
Revert "Maybe fix LSP.tests.test_single_document.SingleDocumentTestCa…
rwols 6e7f252
Fix purge_changes_async in rename.py not being called from the asynci…
rwols a5e3a6d
Rename run_coroutine_threadsafe -> run_coroutine
rwols 135aa60
Fix bug in the rename flow when first making a preview and then click…
rwols 9506bd5
Rename call_soon_threadsafe -> run_in_asyncio_thread
rwols 0e19738
Remove trace() calls from code_actions.py and save_command.py
rwols 45ee4dd
Remove duplicated imports from api.py
rwols ca61cc6
Fix toggling inlay hints
rwols bb41f71
Fix hardcoded value for on-save task timeout
rwols 1529494
Catch the asyncio.CancelledError that's going to be thrown when cance…
rwols 1f14cee
Mark SessionBuffer.request_code_actions_async as deprecated
rwols baec759
There's no need for that opening_files_lock to be used in boot.py
rwols 81e3ab8
Merge branch 'main' into feat/asyncio
rwols 89d8ae9
Simplify types in statement
rwols ff28a4e
Fix running code actions with multiple language servers
rwols 0ab6df7
Prefer apply_workspace_edit over apply_workspace_edit_async
rwols 4801cd6
Merge branch 'main' into feat/asyncio
rwols c7af523
Fix code actions on save
rwols f3d0684
Rename: run_in_asyncio_thread -> run_on_asyncio_thread
rwols 9d2283d
Rename: _run_in_st_thread -> _run_on_st_thread
rwols fbfba1c
Rename: run_in_main_thread -> run_on_main_thread
rwols e39ccf2
Rename: run_in_async_thread -> run_on_async_thread
rwols 4081b04
Rename: wait_until_st_state -> wait_until
rwols 42111fb
Merge branch 'main' into feat/asyncio
rchl f7686b1
debug asyncio.InvalidStateError
rwols 317ff07
Revert "debug asyncio.InvalidStateError"
rwols 54b99af
Allow PostResponseCallback to be a coroutine object
rwols 1dbb546
Tighten exception catching in Session._refresh_text_document_content
rwols ba14429
Add some comments when we invoke loop.run_in_executor
rwols d3a3641
Merge branch 'main' into feat/asyncio
rwols eee901a
Revert "Allow PostResponseCallback to be a coroutine object"
rchl 982079c
simplify
rchl a76cc3e
Fix: don't try to resolve a cancelled future
rwols be9b11f
Make run_tasks a method of LspTextCommandWithTasks
rwols 1bbae7a
Merge branch 'main' into feat/asyncio
rwols 9f8de76
Uncomment line
rwols 965a8df
Make listener.purge_changes_async async
rwols 51066cb
For streaming requests, handle the case where the langserver doesn't …
rwols dee5cac
Merge branch 'main' into feat/asyncio
rwols 62c3211
Use explicit None type for CancellableRequest._id
rwols 5be52cd
Hopefully fix macOS tests?
rwols df6f9d0
Expose property CancellableInflightStreamingRequest.is_streaming
rwols 21763fd
Mark methods for implementation details of CancellableInflightStreami…
rwols 7659c79
Skip unit tests in macOS CI that move files to the Recycle Bin
rwols 8a1b2c7
Rename: next_frame -> tick
rwols 29bff70
Check for future state before resolving it
rwols 87c14dc
Prefer loop.call_soon_threadsafe over run_on_asyncio_thread if we alr…
rwols dac06fc
Add purge_changes_async deprecated method
rwols ce217bc
Keep apply_text_edits promise-based for now
rwols 2dfcd3f
api: make command/uri handlers compatible with async functions too
rwols 1ad342b
Rename: execute_command -> run_command
rwols 513e47f
chore: remove unused parameter in docblock
rwols 7b71e48
Merge branch 'main' into feat/asyncio
rwols 6dc7758
Fix warning PLW0717 from ruff
rwols 52d6814
Rename: run_on_async_thread -> run_on_worker_thread
rwols 13333f0
asyncio.Lock is not needed in transports.py
rwols 80a6066
Just encode/decode JSON on the asyncio thread for now
rwols 86fbc5e
Fix format-on-paste feature
rwols e4702f4
Update plugin/formatting.py
rwols 43ddf5a
lint
rwols ffe524a
Inline MaybeCoroutine type
rwols 76f59a5
Inline redo_later closure
rwols 4b07305
Add method to fake server to get the unused mocks
rwols 5e3e987
Fix code actions ... for real this time?
rwols 74c91b6
When an LspPlugin opts into using asyncio, have the on_pre_start clas…
rwols c8757eb
Merge branch 'main' into feat/asyncio
rwols 8d4ab58
Remove unused test method
rwols 9e13839
Fix code action test... hopefully?
rwols b0b2232
It's not necessary to print the warning from the fake server
rwols ed060ab
refactor usage of LspPlugin.use_asyncio
rwols 1c113d4
Ignore PLW0717 'too many statements in try clause' for now
rwols 4494e7d
Work out why we need two code action response mocks in CodeActionsLis…
rwols 718dd54
Revert "Ignore PLW0717 'too many statements in try clause' for now"
rwols 255824b
Fixup/cleanup more of the code action tests
rwols 350fe3a
fix: SessionBuffer.request_code_actions does not return Error
rwols 9b776af
We cannot make LspPlugin.on_pre_send_request_async async
rwols 80f0e84
Merge branch 'main' into feat/asyncio
rwols 9f2de32
add 'exception_policy' to run_coroutine
rwols 388a1bb
Merge branch 'main' into feat/asyncio
rwols bf43e7c
deal with cancellation
rwols 8c121fb
Fix lint error
rwols 20e875c
Merge branch 'main' into feat/asyncio
rwols 9c2e4db
Merge branch 'main' into feat/asyncio
rwols 0154b19
Replace custom async test case by the new unittesting.AsyncTestCase
rwols 7976d35
Revert "Replace custom async test case by the new unittesting.AsyncTe…
rwols 027537f
Merge branch 'main' into feat/asyncio
rwols e3086d6
Merge branch 'main' into feat/asyncio
rwols 487ad83
Merge branch 'main' into feat/asyncio
rwols ba7e4f1
Return errors by value instead of raising
rwols 1a569c4
Merge branch 'main' into feat/asyncio
rwols 280f4a0
Remove experimental Session.stream method for now
rwols f42d533
Expose 'run_coroutine' and 'run_on_asyncio_thread'
rwols fe7ec2e
Actually return errors by value :)
rwols f1e1721
Fix: checking for 'pending.request' is always True
rwols f53d84e
Remove subclasses of Error
rwols 7697237
fixup tests due to returning Error as value
rwols 0c9c02b
don't report cancellations...
rwols f7f46a1
Merge branch 'main' into feat/asyncio
rwols b0a4181
add function 'run_on_threadpool' to API (that wraps loop.run_in_execu…
rwols 6d06e07
workaround for window/showDocument
rwols 207305a
Revert "workaround for window/showDocument"
rwols c525bd1
Log __del__
rchl 9a0916c
Merge open_uri and try_open_uri, return sublime.View | None
rwols b08d315
use sublime_aio.run_in_worker
rwols 20f2991
Improve type hints in aio.py
rwols 08c4c2d
Fix circular references
rwols 4eda32c
Revert "Log __del__"
rwols c17f86b
Fix potential deadlock
rwols eeddacc
Merge branch 'main' into feat/asyncio
rwols 220fb18
Merge branch 'main' into feat/asyncio
rwols cdf2c8f
Merge branch 'main' into feat/asyncio
rwols d0b059c
return X | BaseException -> return X | Error
rwols 172b05e
Apply timeout per task, instead of a timeout for all the tasks combined
rwols 944bbc4
Tweaks for preparing Session.open_uri to be used at more call sites
rwols c6d729d
make the handling of non-empty code action lists a bit clearer (I hope)
rwols 439896a
Merge branch 'main' into feat/asyncio
rwols f96085a
Fix incorrect merge conflict resolution
rwols 42f94d3
Merge branch 'main' into feat/asyncio
rwols db80534
Update plugin/completion.py (fix auto-imports)
rwols 6d421c6
Allow calling send_request_async from any thread
rwols dac3276
Add some clarifying comments
rwols 55f5cf3
Update old lingering comments about QueryCompletionsTask
rwols c9432b9
Add docblock to _MAX_WAIT_ATTEMPTS
rwols cb2913b
Fix ancient completionItem/resolve rendering bug and simplify
rwols af4235b
Merge branch 'main' into feat/asyncio
rwols f67aa98
update docblock for @uri_handler
rwols 73285fd
Fix ancient completionItem/resolve rendering bug, part 2
rwols c3b112d
Rename: _MAX_WAIT_ATTEMPTS -> _FILE_DELETED_MAX_CHECK_ATTEMPTS
rwols 91c495d
Fix: make Session.{execute_command,run_code_action_async} threadsafe
rwols 936736e
Fix: make DocumentSyncListener.purge_changes_async threadsafe
rwols 9eb5a7b
Merge branch 'main' into feat/asyncio
rwols e1f441c
Rename: CancellableRequest -> RequestController
rwols a81bef5
Rename: CancellableInflightRequest -> CancellableRequest
rwols 1d0b821
Merge branch 'main' into feat/asyncio
rwols 02fcfd3
Organize imports
rwols File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| "bracex", | ||
| "mdpopups", | ||
| "orjson", | ||
| "sublime_aio", | ||
| "typing_extensions", | ||
| "wcmatch" | ||
| ] | ||
|
|
||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.