File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed
Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -918,35 +918,38 @@ impl WasmChallengeExecutor {
918918
919919 // Try to load from distributed storage first
920920 let wasm_bytes = if let Some ( ref storage) = self . config . distributed_storage {
921- // Use spawn_blocking to avoid blocking the async runtime
922921 let storage = Arc :: clone ( storage) ;
923922 let key = platform_distributed_storage:: StorageKey :: new ( "wasm" , module_path) ;
924923
925- // Create a new runtime for blocking context to avoid panic
926- let result = std:: thread:: scope ( |_| {
924+ // Spawn a new thread with its own runtime to avoid nesting runtimes
925+ let ( tx, rx) = std:: sync:: mpsc:: channel ( ) ;
926+ std:: thread:: spawn ( move || {
927927 let rt = tokio:: runtime:: Builder :: new_current_thread ( )
928928 . enable_all ( )
929- . build ( )
930- . ok ( ) ?;
931- rt. block_on ( async {
932- storage
933- . get ( & key, platform_distributed_storage:: GetOptions :: default ( ) )
934- . await
935- . ok ( )
936- . flatten ( )
937- } )
929+ . build ( ) ;
930+ let result = match rt {
931+ Ok ( rt) => rt. block_on ( async {
932+ storage
933+ . get ( & key, platform_distributed_storage:: GetOptions :: default ( ) )
934+ . await
935+ . ok ( )
936+ . flatten ( )
937+ } ) ,
938+ Err ( _) => None ,
939+ } ;
940+ let _ = tx. send ( result) ;
938941 } ) ;
939942
940- match result {
941- Some ( stored) => {
943+ match rx . recv ( ) {
944+ Ok ( Some ( stored) ) => {
942945 info ! (
943946 module = module_path,
944947 size_bytes = stored. data. len( ) ,
945948 "Loading WASM module from distributed storage"
946949 ) ;
947950 Some ( stored. data )
948951 }
949- None => {
952+ _ => {
950953 debug ! (
951954 module = module_path,
952955 "WASM module not found in distributed storage"
You can’t perform that action at this time.
0 commit comments