mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
Revert "Add DEBUG_LOOK in TEST_CASE("Move Subinterpreter")"
This reverts commit ad3e1c34ce.
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
PYBIND11_WARNING_DISABLE_MSVC(4996)
|
PYBIND11_WARNING_DISABLE_MSVC(4996)
|
||||||
|
|
||||||
# include <catch.hpp>
|
# include <catch.hpp>
|
||||||
# include <cstdio>
|
|
||||||
# include <cstdlib>
|
# include <cstdlib>
|
||||||
# include <fstream>
|
# include <fstream>
|
||||||
# include <functional>
|
# include <functional>
|
||||||
@@ -17,16 +16,6 @@ PYBIND11_WARNING_DISABLE_MSVC(4996)
|
|||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
using namespace py::literals;
|
using namespace py::literals;
|
||||||
|
|
||||||
namespace {
|
|
||||||
inline void debug_look(const char *file, int line) {
|
|
||||||
fflush(stderr);
|
|
||||||
std::fprintf(stdout, "\nLOOOK %s:%d\n", file, line);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
# define DEBUG_LOOK() debug_look(__FILE__, __LINE__)
|
|
||||||
|
|
||||||
bool has_state_dict_internals_obj();
|
bool has_state_dict_internals_obj();
|
||||||
uintptr_t get_details_as_uintptr();
|
uintptr_t get_details_as_uintptr();
|
||||||
|
|
||||||
@@ -103,48 +92,30 @@ TEST_CASE("Single Subinterpreter") {
|
|||||||
|
|
||||||
# if PY_VERSION_HEX >= 0x030D0000
|
# if PY_VERSION_HEX >= 0x030D0000
|
||||||
TEST_CASE("Move Subinterpreter") {
|
TEST_CASE("Move Subinterpreter") {
|
||||||
DEBUG_LOOK();
|
|
||||||
std::unique_ptr<py::subinterpreter> sub(new py::subinterpreter(py::subinterpreter::create()));
|
std::unique_ptr<py::subinterpreter> sub(new py::subinterpreter(py::subinterpreter::create()));
|
||||||
DEBUG_LOOK();
|
|
||||||
|
|
||||||
// on this thread, use the subinterpreter and import some non-trivial junk
|
// on this thread, use the subinterpreter and import some non-trivial junk
|
||||||
{
|
{
|
||||||
DEBUG_LOOK();
|
|
||||||
py::subinterpreter_scoped_activate activate(*sub);
|
py::subinterpreter_scoped_activate activate(*sub);
|
||||||
DEBUG_LOOK();
|
|
||||||
|
|
||||||
py::list(py::module_::import("sys").attr("path")).append(py::str("."));
|
py::list(py::module_::import("sys").attr("path")).append(py::str("."));
|
||||||
DEBUG_LOOK();
|
|
||||||
py::module_::import("datetime");
|
py::module_::import("datetime");
|
||||||
DEBUG_LOOK();
|
|
||||||
py::module_::import("threading");
|
py::module_::import("threading");
|
||||||
DEBUG_LOOK();
|
|
||||||
py::module_::import("external_module");
|
py::module_::import("external_module");
|
||||||
DEBUG_LOOK();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOOK();
|
|
||||||
std::thread([&]() {
|
std::thread([&]() {
|
||||||
DEBUG_LOOK();
|
|
||||||
// Use it again
|
// Use it again
|
||||||
{
|
{
|
||||||
DEBUG_LOOK();
|
|
||||||
py::subinterpreter_scoped_activate activate(*sub);
|
py::subinterpreter_scoped_activate activate(*sub);
|
||||||
DEBUG_LOOK();
|
|
||||||
py::module_::import("external_module");
|
py::module_::import("external_module");
|
||||||
DEBUG_LOOK();
|
|
||||||
}
|
}
|
||||||
DEBUG_LOOK();
|
|
||||||
sub.reset();
|
sub.reset();
|
||||||
DEBUG_LOOK();
|
|
||||||
}).join();
|
}).join();
|
||||||
DEBUG_LOOK();
|
|
||||||
|
|
||||||
REQUIRE(!sub);
|
REQUIRE(!sub);
|
||||||
DEBUG_LOOK();
|
|
||||||
|
|
||||||
unsafe_reset_internals_for_single_interpreter();
|
unsafe_reset_internals_for_single_interpreter();
|
||||||
DEBUG_LOOK();
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user