From 3a8dc0e2117bdbbae3f623dcf6f215011e33acfd Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jul 2020 05:58:59 -0700 Subject: [PATCH] fix(tests): prevent postgres::pool_smoke_test from starving executor --- tests/postgres/postgres.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index 67f95b61..2f38b614 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -6,6 +6,7 @@ use sqlx::postgres::{ use sqlx::{postgres::Postgres, Connect, Connection, Executor, PgPool, Row}; use sqlx_test::new; use std::env; +use std::thread; use std::time::Duration; #[sqlx_macros::test] @@ -391,7 +392,9 @@ async fn pool_smoke_test() -> anyhow::Result<()> { for _ in 0..5 { let pool = pool.clone(); - spawn(async move { + // we don't need async, just need this to run concurrently + // if we use `task::spawn()` we risk starving the event loop because we don't yield + thread::spawn(move || { while !pool.is_closed() { // drop acquire() futures in a hot loop // https://github.com/launchbadge/sqlx/issues/83