]> Repositorios git - scryer-prolog.git/commitdiff
Deactivate tokio runtime respawning on interrupt
authorNicolas Luck <[email protected]>
Thu, 5 Oct 2023 10:11:28 +0000 (12:11 +0200)
committerNicolas Luck <[email protected]>
Thu, 5 Oct 2023 10:11:28 +0000 (12:11 +0200)
src/machine/dispatch.rs
src/machine/system_calls.rs

index 23fe7c029f87d39cb63489af7b2b92ee6707bd5b..771fe91f410265eb842e5bb2d77a3b39e2e31b8b 100644 (file)
@@ -5269,16 +5269,22 @@ impl Machine {
                         self.machine_st.throw_interrupt_exception();
                         self.machine_st.backtrack();
 
-                       #[cfg(not(target_arch = "wasm32"))]
-                       let runtime = tokio::runtime::Runtime::new().unwrap();
-                       #[cfg(target_arch = "wasm32")]
-                       let runtime = tokio::runtime::Builder::new_current_thread()
-                           .enable_all()
-                           .build()
-                           .unwrap();
-
-                       let old_runtime = std::mem::replace(&mut self.runtime, runtime);
-                       old_runtime.shutdown_background();
+                        // We have extracted controll over the Tokio runtime to the calling context for enabling library use case
+                        // (see https://github.com/mthom/scryer-prolog/pull/1880)
+                        // So we only have access to a runtime handle in here and can't shut it down.
+                        // Since I'm not aware of the consequences of deactivating this new code which came in while PR 1880
+                        // was not merged, I'm only deactivating it for now.
+                        
+                        //#[cfg(not(target_arch = "wasm32"))]
+                        //let runtime = tokio::runtime::Runtime::new().unwrap();
+                        //#[cfg(target_arch = "wasm32")]
+                        //let runtime = tokio::runtime::Builder::new_current_thread()
+                        //    .enable_all()
+                        //    .build()
+                        //    .unwrap();
+
+                        //let old_runtime = tokio::runtime::Handle::current();
+                        //old_runtime.shutdown_background();
                     }
                 }
                 Err(_) => unreachable!(),
index 86fededf7238c8343a970dabf24ff9ea16591038..5c482636a48c37f9931f29d2295c5325c468414c 100644 (file)
@@ -4615,8 +4615,13 @@ impl Machine {
                                        if interruption {
                                            self.machine_st.throw_interrupt_exception();
                                            self.machine_st.backtrack();
-                                           let old_runtime = std::mem::replace(&mut self.runtime, tokio::runtime::Runtime::new().unwrap());
-                                           old_runtime.shutdown_background();
+                        // We have extracted controll over the Tokio runtime to the calling context for enabling library use case
+                        // (see https://github.com/mthom/scryer-prolog/pull/1880)
+                        // So we only have access to a runtime handle in here and can't shut it down.
+                        // Since I'm not aware of the consequences of deactivating this new code which came in while PR 1880
+                        // was not merged, I'm only deactivating it for now.
+                                           //let old_runtime = std::mem::replace(&mut self.runtime, tokio::runtime::Runtime::new().unwrap());
+                                           //old_runtime.shutdown_background();
                                            break
                                        }
                                    }