Skip to content

Commit

Permalink
Merge pull request #1268 from davidhewitt/move-misc-test
Browse files Browse the repository at this point in the history
rustapi_module: move issue_219 regression test
  • Loading branch information
davidhewitt committed Nov 10, 2020
2 parents 9a70301 + 126a748 commit 5daadd4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/rustapi_module/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ def make_rust_extension(module_name):
rust_extensions=[
make_rust_extension("rustapi_module.buf_and_str"),
make_rust_extension("rustapi_module.datetime"),
make_rust_extension("rustapi_module.misc"),
make_rust_extension("rustapi_module.objstore"),
make_rust_extension("rustapi_module.othermod"),
make_rust_extension("rustapi_module.pyclass_iter"),
make_rust_extension("rustapi_module.subclassing"),
make_rust_extension("rustapi_module.test_dict"),
make_rust_extension("rustapi_module.pyclass_iter"),
],
include_package_data=True,
zip_safe=False,
Expand Down
8 changes: 0 additions & 8 deletions examples/rustapi_module/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,6 @@ fn datetime_from_timestamp<'p>(
PyDateTime::from_timestamp(py, ts, tz)
}

#[pyfunction]
fn issue_219() -> PyResult<()> {
let gil = Python::acquire_gil();
let _py = gil.python();
Ok(())
}

#[pyclass(extends=PyTzInfo)]
pub struct TzClass {}

Expand Down Expand Up @@ -234,7 +227,6 @@ fn datetime(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(get_datetime_tuple_fold, m)?)?;
}

m.add_function(wrap_pyfunction!(issue_219, m)?)?;
m.add_class::<TzClass>()?;

Ok(())
Expand Down
1 change: 1 addition & 0 deletions examples/rustapi_module/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod buf_and_str;
pub mod datetime;
pub mod dict_iter;
pub mod misc;
pub mod objstore;
pub mod othermod;
pub mod pyclass_iter;
Expand Down
16 changes: 16 additions & 0 deletions examples/rustapi_module/src/misc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

#[pyfunction]
fn issue_219() -> PyResult<()> {
// issue 219: acquiring GIL inside #[pyfunction] deadlocks.
let gil = Python::acquire_gil();
let _py = gil.python();
Ok(())
}

#[pymodule]
fn misc(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(issue_219, m)?)?;
Ok(())
}
4 changes: 0 additions & 4 deletions examples/rustapi_module/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,6 @@ def test_delta_err(args, err_type):
rdt.make_delta(*args)


def test_issue_219():
rdt.issue_219()


def test_tz_class():
tzi = rdt.TzClass()

Expand Down
6 changes: 6 additions & 0 deletions examples/rustapi_module/tests/test_misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import rustapi_module.misc


def test_issue_219():
# Should not deadlock
rustapi_module.misc.issue_219()

0 comments on commit 5daadd4

Please sign in to comment.