From 9414a9fc2992239118c0d67633ca78a29c2d8b11 Mon Sep 17 00:00:00 2001 From: highflowey Date: Fri, 23 Aug 2024 15:27:51 +0330 Subject: [PATCH] unlock mutex before using async --- crates/lune-std/src/globals/require/context.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/lune-std/src/globals/require/context.rs b/crates/lune-std/src/globals/require/context.rs index c38c694..5f0329c 100644 --- a/crates/lune-std/src/globals/require/context.rs +++ b/crates/lune-std/src/globals/require/context.rs @@ -102,8 +102,13 @@ impl RequireContext { let pending = data_ref.pending.try_lock()?; - if let Some(a) = pending.get(&path_abs) { - a.subscribe().recv().await?; + if let Some(sender) = pending.get(&path_abs) { + let mut receiver = sender.subscribe(); + + // unlock mutex before using async + drop(pending); + + receiver.recv().await?; } }