Skip to content

Commit 7ab3463

Browse files
authored
Wait for test server to shutdown (#11485)
1 parent 7852771 commit 7ab3463

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ iter_on_empty_collections = "warn"
647647
iter_on_single_items = "warn"
648648
iter_without_into_iter = "warn"
649649
large_digit_groups = "warn"
650+
large_futures = "warn"
650651
large_include_file = "warn"
651652
large_stack_arrays = "warn"
652653
large_stack_frames = "warn"
@@ -738,6 +739,7 @@ unnecessary_semicolon = "warn"
738739
unnecessary_struct_initialization = "warn"
739740
unnecessary_wraps = "warn"
740741
unnested_or_patterns = "warn"
742+
unused_async = "warn"
741743
unused_peekable = "warn"
742744
unused_rounding = "warn"
743745
unused_self = "warn"

crates/store/re_server/src/server.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct Server {
3939
/// `ServerHandle` is a tiny helper abstraction that enables us to
4040
/// deal with the gRPC server lifecycle more easily.
4141
pub struct ServerHandle {
42-
shutdown: Sender<()>,
42+
shutdown: Option<Sender<()>>,
4343
ready: mpsc::Receiver<SocketAddr>,
4444
failed: mpsc::Receiver<String>,
4545
}
@@ -73,9 +73,12 @@ impl ServerHandle {
7373
self.failed.recv().await;
7474
}
7575

76-
/// Signal to the gRPC server to shutdown.
77-
pub async fn shutdown(self) {
78-
let _ = self.shutdown.send(());
76+
/// Signal to the gRPC server to shutdown, and then wait for it.
77+
pub async fn shutdown_and_wait(mut self) {
78+
if let Some(shutdown) = self.shutdown.take() {
79+
shutdown.send(()).ok();
80+
self.wait_for_shutdown().await;
81+
}
7982
}
8083
}
8184

@@ -151,7 +154,7 @@ impl Server {
151154
});
152155

153156
ServerHandle {
154-
shutdown: shutdown_tx,
157+
shutdown: Some(shutdown_tx),
155158
ready: ready_rx,
156159
failed: failed_rx,
157160
}

tests/rust/re_integration_test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Drop for TestServer {
7070
.expect("Server handle not initialized");
7171
tokio::task::block_in_place(move || {
7272
tokio::runtime::Handle::current().block_on(async move {
73-
server_handle.shutdown().await;
73+
server_handle.shutdown_and_wait().await;
7474
});
7575
});
7676
}

0 commit comments

Comments
 (0)