-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pymodule: only allow initializing once per process
- Loading branch information
1 parent
8bc86c3
commit a34bd4d
Showing
5 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
import importlib | ||
import platform | ||
|
||
import pyo3_pytests.misc | ||
import pytest | ||
|
||
|
||
def test_issue_219(): | ||
# Should not deadlock | ||
pyo3_pytests.misc.issue_219() | ||
|
||
|
||
@pytest.mark.skipif( | ||
platform.python_implementation() == "PyPy", | ||
reason="PyPy does not reinitialize the module (appears to be some internal caching)", | ||
) | ||
def test_second_module_import_fails(): | ||
spec = importlib.util.find_spec("pyo3_pytests.pyo3_pytests") | ||
|
||
with pytest.raises( | ||
ImportError, | ||
match="PyO3 modules may only be initialized once per interpreter process", | ||
): | ||
importlib.util.module_from_spec(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters