forked from openlawlibrary/pygls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: re-implement pygls' builtin handlers using generators
The underlying cause of openlawlibrary#433 is that pygls' current implementation of builtin feature handlers cannot guarantee that an async user handler will finish executing before pygls responds with the answer generated from the builtin handler. This commit adds support for another execution model, generators. A generator handler can yield to another sub-handler method like so ``` yield handler_func, args, kwargs ``` The `JsonRPCProtocol` class with then schedule the execution of `handler_func(*args, **kwargs)` as if it were a normal handler function (meaning `handler_func could be async, threaded, sync or a generator itself!) The result of the sub-handler is then sent back into the generator handler allowing the top-level handler to continue and even make use of the result! This gives pygls' built-in handlers much greater control over exactly when a user handler is called, allowing us to fix openlawlibrary#433 and opens up a lot other exciting possibilities! This also removes the need for the `LSPMeta` metaclass, so it and the corresponding module have been deleted.
- Loading branch information
Showing
5 changed files
with
173 additions
and
146 deletions.
There are no files selected for viewing
This file contains 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 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.