MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / test_thread_exit_py

Function test_thread_exit_py

tests/test_thread_exit.rs:4–20  ·  view source on GitHub ↗
(py: Python)

Source from the content-addressed store, hash-verified

2
3#[allow(unused)]
4fn test_thread_exit_py(py: Python) -> PyResult<()> {
5 let m = py.import("sys")?;
6 m.add(py, "exit_thread", py_fn!(py, exit_thread()))?;
7 py.run(
8 "
9import sys, threading
10# should not abort
11threading.Thread(target=sys.exit_thread).start()
12",
13 None,
14 None,
15 )?;
16 py.allow_threads(|| {
17 std::thread::sleep(std::time::Duration::from_millis(100));
18 });
19 Ok(())
20}
21
22// This test requires Rust 1.40, namely
23// https://github.com/rust-lang/rust/pull/65646.

Callers 1

test_thread_exitFunction · 0.85

Calls 4

runMethod · 0.80
allow_threadsMethod · 0.80
importMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected