| 116 | } |
| 117 | |
| 118 | fn 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 | |
| 162 | async fn datafusion(store: Arc<dyn ObjectStore>) -> Result<()> { |
| 163 | let query = "SELECT distinct \"A\", \"B\", \"C\", \"D\", \"E\" FROM \"test_table\""; |