Skip to content

Commit d1ec057

Browse files
committed
block on init chromium
1 parent d89534d commit d1ec057

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/template/render.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ pub async fn init() -> Result<(), Box<dyn Error>> {
3535
get_jinja_engine();
3636
tracing::info!("init jinja done!");
3737
tracing::info!("init chromium...");
38-
loop {
39-
match get_chromium_tab() {
40-
Ok(_) => {
41-
tracing::info!("init chromium done!");
42-
return Ok(());
38+
tokio::task::spawn_blocking(move || {
39+
loop {
40+
match get_chromium_tab() {
41+
Ok(_) => {
42+
tracing::info!("init chrome done!");
43+
break;
44+
}
45+
Err(e) => tracing::warn!("chrome not available yet! will try again in a sec...{e}"),
4346
}
44-
Err(e) => tracing::warn!("chrome not available yet! will try again in a sec...{e}"),
47+
std::thread::sleep(Duration::from_secs(30));
4548
}
46-
tokio::time::sleep(Duration::from_secs(30)).await;
47-
}
49+
})
50+
.await?;
51+
Ok(())
4852
}
4953

5054
pub async fn render<T: Serialize + Debug>(
@@ -162,7 +166,7 @@ pub fn get_chromium_tab() -> Result<Arc<Tab>, Box<dyn Error>> {
162166
// OsStr::new("--disable-setuid-sandbox"),
163167
OsStr::new("--disable-features=IsolateOrigins,site-per-process"),
164168
// OsStr::new("--default-background-color=00000000"),
165-
OsStr::new("--disable-dev-shm-usage"),
169+
OsStr::new("--disable-dev-shm-usage"),
166170
&user_data_dir,
167171
])
168172
.build()

0 commit comments

Comments
 (0)