chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

View File

@@ -0,0 +1,72 @@
#![cfg(all(
feature = "managed",
any(feature = "rt_tokio_1", feature = "rt_async-std_1")
))]
use std::{convert::Infallible, future::Future, pin::Pin, task, time::Duration};
use deadpool::{
managed::{self, Metrics, Object, PoolConfig, PoolError, RecycleResult, Timeouts},
Runtime,
};
type Pool = managed::Pool<Manager, Object<Manager>>;
struct Manager {}
struct Never;
impl Future for Never {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
task::Poll::Pending
}
}
impl managed::Manager for Manager {
type Type = usize;
type Error = Infallible;
async fn create(&self) -> Result<usize, Infallible> {
Never.await;
unreachable!();
}
async fn recycle(&self, _conn: &mut usize, _: &Metrics) -> RecycleResult<Infallible> {
Never.await;
unreachable!();
}
}
async fn test_managed_timeout(runtime: Runtime) {
let mgr = Manager {};
let cfg = PoolConfig {
max_size: 16,
timeouts: Timeouts {
create: Some(Duration::from_millis(0)),
wait: Some(Duration::from_millis(0)),
recycle: Some(Duration::from_millis(0)),
},
..Default::default()
};
let pool = Pool::builder(mgr)
.config(cfg)
.runtime(runtime)
.build()
.unwrap();
assert!(matches!(pool.get().await, Err(PoolError::Timeout(_))));
}
#[cfg(feature = "rt_tokio_1")]
#[tokio::test]
async fn rt_tokio_1() {
test_managed_timeout(Runtime::Tokio1).await;
}
#[cfg(feature = "rt_async-std_1")]
#[async_std::test]
async fn rt_async_std_1() {
test_managed_timeout(Runtime::AsyncStd1).await;
}