You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I wanted to know if it's possible to create two separate python virtual machines in two different threads?
This is pseudocode
`
int main()
{
std::jthread t1{ []
{
py::scoped_interpreter guard{};
while (true)
{
py::print("Hello from thread 1");
}
}};
std::jthread t2{ []
{
py::scoped_interpreter guard{};
while (true)
{
py::print("Hello from thread 2");
}
}};
while (true);
}
`
Please ignore the fact that simultaneous calls to stdout is not safe.
I'm doing this for my plugin api and my idea is that each plugin would have its own fully separated python virtual machine (interpreter) with its own environment.
Right now it crashes, and if something I want is not possible because of the implementation of Pybind11, can anyone link me to the library which supports separate python virtual machines?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I wanted to know if it's possible to create two separate python virtual machines in two different threads?
This is pseudocode
`
int main()
{
std::jthread t1{ []
{
py::scoped_interpreter guard{};
while (true)
{
py::print("Hello from thread 1");
}
}};
}
`
Please ignore the fact that simultaneous calls to stdout is not safe.
I'm doing this for my plugin api and my idea is that each plugin would have its own fully separated python virtual machine (interpreter) with its own environment.
Right now it crashes, and if something I want is not possible because of the implementation of Pybind11, can anyone link me to the library which supports separate python virtual machines?
Beta Was this translation helpful? Give feedback.
All reactions