Replies: 4 comments 37 replies
-
Hello @Aequitosh, I accepted to enter the fork of PyO3, and I'm doing some planing here of what files to change first, as we talk in the main thread on David account it will be nice to add the lacking ffi support, I'm already doing part of the C API extension in the rust module to the impl that we are proposing on the enhancement of adding sub compilers, I think until the end of the week I have something promising to we test, also feel free to share your ideas and opinions about the topic too, let's keep talking! |
Beta Was this translation helpful? Give feedback.
-
I will add the things that we discuss with David on the other issue, what you think is a good practice, do directly on main since it's a fork or create a branch that we can cut when we finish? |
Beta Was this translation helpful? Give feedback.
-
I will start a new branch of our discussion here just to brainstorm a potential thing if the nogil becomes very, very hard to implement . and discuss if it makes any sense: This idea was sneaking around in my mind since the start, however, I was not sure if it can work or not, however this line here:
From this paragraph:
Of this PEP 703 that you mentioned makes me think about this idea again, basically, at least at the point that I know we can only have one GIL for session since this will lock the global interpreter and we will only be able to use it in a unique thread wright? What if we build a mechanism that create multiple sessions in Rust side and then we control each one from a head controler? This way each one will have their own GIL. It will looks like python default subprocess since the def of it says:
So this will allow us to use most part of the built structure in a way that we only need to build a mechanism to parallelize it in multiple sessions then share (in the rust side) a secure state of each one, this will looks something like the following: graph TD
subgraph Main[Main]
style Main stroke:#2FFFFF, fill:#00FFFF ,fill-opacity:0.1
XX[Head]
end
subgraph Controler[Controler]
style Controler stroke:#a14FFF, fill:#a14FFF ,fill-opacity:0.1
subgraph Process1[Process1]
style Process1 stroke:#a14FFF, fill:#a14FFF ,fill-opacity:0.1
A[Lock GIL]
B[GIL]
C[Aquire Python]
D[Use Python]
E[Drop Python]
F[Drop Drop GIL]
XX --> A
A --> B
B --> |GIL Lock| C
C --> |Python| D
B --> |GIL Lock| F
D --> E
C --> |Python| E
E --> F
end
subgraph Process2[Process2]
style Process2 stroke:#a14FFF, fill:#a14FFF ,fill-opacity:0.1
N[Lock GIL]
O[GIL]
P[Aquire Python]
Q[Use Python]
R[Drop Python]
S[Drop Drop GIL]
XX --> N
N --> O
O --> |GIL Lock| P
P --> |Python| Q
P --> |Python| R
Q --> R
N --> |GIL Lock| S
R --> S
end
subgraph Process3[Process3]
style Process3 stroke:#a14FFF, fill:#a14FFF ,fill-opacity:0.1
T[Lock GIL]
U[GIL]
V[Aquire Python]
W[Use Python]
X[Drop Python]
Y[Drop Drop GIL]
XX --> T
T --> U
U --> |GIL Lock| V
V --> |Python| W
W --> X
V --> |Python| X
X --> Y
V --> |GIL Lock| Y
end
end
I was trying to do something like this in my crate RustPyNet that I built to help the use of PyO3 in a batch sequence queue from multiple threads executing python task in various treads in an orchestrated way, this crate is in my public profile and in a branch named: |
Beta Was this translation helpful? Give feedback.
-
FYI: I've decided to publish my development environment, so you can follow up on whatever I'm currently up to. I'll include a way to automatically use development builds of PyO3 in the near future to make everything a little easier for myself. |
Beta Was this translation helpful? Give feedback.
-
All relevant discussion regarding the design and development of sub-interpreter support should preferably go on here (until we find a better place, but I think this will do).
I'll post my thoughts and findings here from time to time, and if you're reading this, you're more than welcome to pitch in!
Edit: The tracking issue can be found here: PyO3#3451
Beta Was this translation helpful? Give feedback.
All reactions