mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-04 14:53:25 +02:00
fix(core): Fix async panic on blocking #19
Replaced internal threads with tokio spawn functions
This commit is contained in:
@@ -11,17 +11,17 @@ impl Engine {
|
||||
Self {}
|
||||
}
|
||||
|
||||
fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
let cli = Downloader::new("0.3.12".into())?.get_cli()?;
|
||||
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
let cli = Downloader::new("0.3.12".into())?.get_cli().await?;
|
||||
|
||||
let cli_session = CliSession::new();
|
||||
|
||||
Ok(cli_session.connect(cfg, &cli)?)
|
||||
Ok(cli_session.connect(cfg, &cli).await?)
|
||||
}
|
||||
|
||||
pub fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
pub async fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
// TODO: Add from existing session as well
|
||||
self.from_cli(cfg)
|
||||
self.from_cli(cfg).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ mod tests {
|
||||
use super::Engine;
|
||||
|
||||
// TODO: these tests potentially have a race condition
|
||||
#[test]
|
||||
fn engine_can_start() {
|
||||
#[tokio::test]
|
||||
async fn engine_can_start() {
|
||||
let engine = Engine::new();
|
||||
let params = engine.start(&Config::new(None, None, None, None)).unwrap();
|
||||
let params = engine.start(&Config::new(None, None, None, None)).await.unwrap();
|
||||
|
||||
assert_ne!(
|
||||
params.0,
|
||||
|
Reference in New Issue
Block a user