MCPcopy Create free account
hub / github.com/apache/datafusion / run_test

Function run_test

benchmarks/src/cancellation.rs:118–160  ·  view source on GitHub ↗
(wait_time: u64, store: Arc<dyn ObjectStore>)

Source from the content-addressed store, hash-verified

116}
117
118fn run_test(wait_time: u64, store: Arc<dyn ObjectStore>) -> Result<Duration> {
119 std::thread::spawn(move || {
120 let token = CancellationToken::new();
121 let captured_token = token.clone();
122
123 let rt = Runtime::new()?;
124 rt.spawn(async move {
125 println!("Starting spawned");
126 loop {
127 let store = Arc::clone(&store);
128 tokio::select! {
129 biased;
130 _ = async move {
131 datafusion(store).await.unwrap();
132 } => {
133 println!("matched case doing work");
134 },
135 _ = captured_token.cancelled() => {
136 println!("Received shutdown request");
137 return;
138 },
139 }
140 }
141 });
142
143 println!("in main, sleeping");
144 std::thread::sleep(Duration::from_millis(wait_time));
145
146 let start = Instant::now();
147
148 println!("cancelling thread");
149 token.cancel();
150
151 drop(rt);
152
153 let elapsed = start.elapsed();
154 println!("done dropping runtime in {elapsed:?}");
155
156 Ok(elapsed)
157 })
158 .join()
159 .unwrap()
160}
161
162async fn datafusion(store: Arc<dyn ObjectStore>) -> Result<()> {
163 let query = "SELECT distinct \"A\", \"B\", \"C\", \"D\", \"E\" FROM \"test_table\"";

Callers 1

runMethod · 0.70

Calls 4

newFunction · 0.85
joinMethod · 0.45
cloneMethod · 0.45
spawnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…