mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-13 05:46:17 +00:00
migrate all async tokio to server & swap to single-thread runtime (#149)
This commit is contained in:
parent
c29b268326
commit
def9fba2b6
12 changed files with 45 additions and 103 deletions
|
@ -1,9 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::ValueEnum;
|
||||
use djls_server::DjangoLanguageServer;
|
||||
use tower_lsp_server::LspService;
|
||||
use tower_lsp_server::Server;
|
||||
|
||||
use crate::args::Args;
|
||||
use crate::commands::Command;
|
||||
|
@ -23,28 +20,14 @@ enum ConnectionType {
|
|||
|
||||
impl Command for Serve {
|
||||
fn execute(&self, _args: &Args) -> Result<Exit> {
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
djls_server::run()?;
|
||||
|
||||
let exit_status = runtime.block_on(async {
|
||||
let stdin = tokio::io::stdin();
|
||||
let stdout = tokio::io::stdout();
|
||||
|
||||
let (service, socket) = LspService::build(DjangoLanguageServer::new).finish();
|
||||
|
||||
Server::new(stdin, stdout, socket).serve(service).await;
|
||||
|
||||
// Exit here instead of returning control to the `Cli`, for ... reasons?
|
||||
// If we don't exit here, ~~~ something ~~~ goes on with PyO3 (I assume)
|
||||
// or the Python entrypoint wrapper to indefinitely hang the CLI and keep
|
||||
// the process running
|
||||
Exit::success()
|
||||
.with_message("Server completed successfully")
|
||||
.process_exit()
|
||||
});
|
||||
|
||||
Ok(exit_status)
|
||||
// Exit here instead of returning control to the `Cli`, for ... reasons?
|
||||
// If we don't exit here, ~~~ something ~~~ goes on with PyO3 (I assume)
|
||||
// or the Python entrypoint wrapper to indefinitely hang the CLI and keep
|
||||
// the process running
|
||||
Exit::success()
|
||||
.with_message("Server completed successfully")
|
||||
.process_exit()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue