Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use async Mutext #595

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/policy_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ async fn create_verifier(
mod tests {
use super::*;
use lazy_static::lazy_static;
use std::sync::Mutex;
use tempfile::TempDir;
use tokio::runtime::Runtime;
use tokio::{runtime::Runtime, sync::Mutex};

lazy_static! {
// Allocate the DOWNLOADER once, this is needed to reduce the execution time
Expand Down Expand Up @@ -319,14 +318,14 @@ mod tests {
// This is required to have lazy_static create the object right now,
// outside of the tokio runtime. Creating the object inside of the tokio
// rutime causes a panic because sigstore-rs' code invokes a `block_on` too
let downloader = DOWNLOADER.lock().unwrap();
let downloader = DOWNLOADER.lock();
drop(downloader);

let rt = Runtime::new().unwrap();
let fetched_policies = rt.block_on(async {
DOWNLOADER
.lock()
.unwrap()
.await
.download_policies(
&policies,
policy_download_dir.path().to_str().unwrap(),
Expand Down Expand Up @@ -366,14 +365,14 @@ mod tests {
// This is required to have lazy_static create the object right now,
// outside of the tokio runtime. Creating the object inside of the tokio
// rutime causes a panic because sigstore-rs' code invokes a `block_on` too
let downloader = DOWNLOADER.lock().unwrap();
let downloader = DOWNLOADER.lock();
drop(downloader);

let rt = Runtime::new().unwrap();
let err = rt.block_on(async {
DOWNLOADER
.lock()
.unwrap()
.await
.download_policies(
&policies,
policy_download_dir.path().to_str().unwrap(),
Expand Down
Loading