Skip to content

Commit

Permalink
Rust nailgun client kinda works
Browse files Browse the repository at this point in the history
[ci skip-build-wheels]
  • Loading branch information
gshuflin committed Sep 27, 2020
1 parent 04d2a91 commit ef46758
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/python/pants/bin/remote_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ def _connect_and_execute(self, pantsd_handle: PantsDaemonClient.Handle) -> ExitC
logger.info(f"rust client: {rust_client}")

output = rust_client.execute(port, command, args, modified_env)
logger.info(f"OUTPUT: {output}")
#logger.info(f"OUTPUT: {output}")

timeout = global_options.pantsd_pailgun_quit_timeout
pantsd_signal_handler = PailgunClientSignalHandler(client, pid=pid, timeout=timeout)
with ExceptionSink.trapped_signals(pantsd_signal_handler), STTYSettings.preserved():
output = rust_client.execute(port, command, args, modified_env)
# Execute the command on the pailgun.
return client.execute(self._args[0], self._args[1:], modified_env)
#return client.execute(self._args[0], self._args[1:], modified_env)

def _extract_remote_exception(self, pantsd_pid, nailgun_error):
"""Given a NailgunError, returns a Terminated exception with additional info (where
Expand Down
34 changes: 19 additions & 15 deletions src/rust/engine/nailgun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ async fn handle_client_input(mut stdin_write: mpsc::Sender<ChildInput>) -> Resul
}

pub async fn client_execute(port: u16, command: String, args: Vec<String>, env: Vec<(String, String)>) -> i32 {
use std::time::Duration;
//use std::time::Duration;
use nails::execution::{child_channel, Command};


let _config = Config::default().heartbeat_frequency(Duration::from_millis(500));
let _command = Command {
let config = Config::default();/*.heartbeat_frequency(Duration::from_millis(500));*/
let command = Command {
command,
args,
env,
Expand All @@ -108,25 +107,30 @@ pub async fn client_execute(port: u16, command: String, args: Vec<String>, env:
let (stdio_write, stdio_read) = child_channel::<ChildOutput>();
let (stdin_write, stdin_read) = child_channel::<ChildInput>();

let output_handler = tokio::spawn(handle_client_output(stdio_read));
let _input_handler = tokio::spawn(handle_client_input(stdin_write));

let localhost = std::net::Ipv4Addr::new(127, 0, 0, 1);
let addr = (localhost, port);
let _stream = TcpStream::connect(addr);
/*
let exit_code = stream.and_then(|socket| {
nails::handle_client_connection(

let socket = TcpStream::connect(addr).await.unwrap();
let exit_code: ExitCode = nails::client_handle_connection(
config,
socket
socket,
command,
stdio_write,
stdin_read,
);
})
.await;
*/
)
.await
.unwrap();

output_handler
.await
.unwrap()
.unwrap();

let exit_code = 4;
exit_code
//let exit_code = 4;
exit_code.0
}

pub struct Server {
Expand Down

0 comments on commit ef46758

Please sign in to comment.