fix: use new_current_thread runtime in get_database_url_sync to prevent nested block_on panic
All checks were successful
BotServer CI/CD / build (push) Successful in 6m30s
All checks were successful
BotServer CI/CD / build (push) Successful in 6m30s
This commit is contained in:
parent
f6a864aa67
commit
263ca4ed11
1 changed files with 7 additions and 1 deletions
|
|
@ -54,7 +54,13 @@ pub fn get_database_url_sync() -> Result<String> {
|
|||
let guard = SECRETS_MANAGER.read().map_err(|e| anyhow::anyhow!("Lock poisoned: {}", e))?;
|
||||
if let Some(ref manager) = *guard {
|
||||
if let Ok(handle) = tokio::runtime::Handle::try_current() {
|
||||
return handle.block_on(manager.get_database_url());
|
||||
return tokio::task::block_in_place(|| {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.map_err(|e| anyhow::anyhow!("Failed to create runtime: {}", e))?;
|
||||
rt.block_on(manager.get_database_url())
|
||||
});
|
||||
} else {
|
||||
let rt = tokio::runtime::Runtime::new()
|
||||
.map_err(|e| anyhow::anyhow!("Failed to create runtime: {}", e))?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue