Checks for triggered signals and calls the appropriate handlers. A no-op on platforms where signals are not supported.
(&self)
| 2016 | /// Checks for triggered signals and calls the appropriate handlers. A no-op on |
| 2017 | /// platforms where signals are not supported. |
| 2018 | pub fn check_signals(&self) -> PyResult<()> { |
| 2019 | #[cfg(feature = "threading")] |
| 2020 | if self.state.finalizing.load(Ordering::Acquire) && !self.is_main_thread() { |
| 2021 | // once finalization starts, |
| 2022 | // non-main Python threads should stop running bytecode. |
| 2023 | return Err(self.new_exception(self.ctx.exceptions.system_exit.to_owned(), vec![])); |
| 2024 | } |
| 2025 | |
| 2026 | // Suspend this thread if stop-the-world is in progress |
| 2027 | #[cfg(all(unix, feature = "threading"))] |
| 2028 | thread::suspend_if_needed(&self.state.stop_the_world); |
| 2029 | |
| 2030 | #[cfg(not(target_arch = "wasm32"))] |
| 2031 | { |
| 2032 | crate::signal::check_signals(self) |
| 2033 | } |
| 2034 | #[cfg(target_arch = "wasm32")] |
| 2035 | { |
| 2036 | Ok(()) |
| 2037 | } |
| 2038 | } |
| 2039 | |
| 2040 | pub(crate) fn push_exception(&self, exc: Option<PyBaseExceptionRef>) { |
| 2041 | self.exceptions.borrow_mut().stack.push(exc); |
no test coverage detected