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
I'm building a multi-node network simulation where each node runs independently and can execute Python applications through PyO3. The architecture involves:
Multiple VNode instances running in separate Tokio tasks/threads
Python applications registered on each node via PyObject instances
Asynchronous message passing between nodes
Periodic execution of Python methods (some_method, etc.)
"isolated Python contexts" it sounds like what you might want is subinterpreters, as per your (3). They have historically been an esoteric feature in CPython however getting more support, however we don't yet have a path to support them in PyO3 - Support sub-interpreters #576 . Can you make the state encapsulated onto a class so you don't need truly "global" state?
If you want to avoid the GIL you should look at Python 3.14's free threaded Python.
As per 1.
I'm not sure I have anything here I would define as "best practice", I think it's quite context depended. For example subprocesses might be acceptable to you if strong isolation is a hard requirement and the serialization costs are not prohibitive?
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
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I'm building a multi-node network simulation where each node runs independently and can execute Python applications through PyO3. The architecture involves:
The Problem
When multiple nodes execute their Python applications simultaneously across different threads, I'm experiencing:
Specific Questions
Current Workaround Attempt
I've tried using py.allow_threads() with nested Python::with_gil(), but this doesn't seem to provide the isolation I need:
Beta Was this translation helpful? Give feedback.
All reactions