Skip to content

Is there anything like GIL? #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yanchenghust opened this issue Jul 24, 2019 · 8 comments
Closed

Is there anything like GIL? #64

yanchenghust opened this issue Jul 24, 2019 · 8 comments
Labels
question Further information is requested

Comments

@yanchenghust
Copy link

As we know, CPython implemention has a GIL.
How about gpython?

@ncw
Copy link
Collaborator

ncw commented Jul 24, 2019

gpython does not contain a GIL.

However it does not, as yet allow any sort of multiprocessing.

It is my plan to make a threading library which under the hood creates go routines. At this point it will need some sort of locking...

@ncw ncw added the question Further information is requested label Jul 24, 2019
@sbinet
Copy link
Member

sbinet commented Jul 29, 2019

by threading library, you mean exposing a gpython module to the Python interpreter, right?

the skylark Python-like VM has actually the concept of a Thread state that is passed to each API call...

WDYT about this?

@ncw
Copy link
Collaborator

ncw commented Jul 29, 2019

by threading library, you mean exposing a gpython module to the Python interpreter, right?

Yes. My plan was to make a low level module exposing some go features like goroutines, channels, locks etc, and use that low level module to build up something which was API compatible with the threading module.

the skylark Python-like VM has actually the concept of a Thread state that is passed to each API call...

That sounds like a job for a context passed everywhere. We've already identified somewhere else that would be very useful! Go having no thread local storage makes it very difficult to translate some bits of python.

WDYT about this?

I think we'd almost certainly need something very similar! I'd propose to attach it to a context though.

@sbinet
Copy link
Member

sbinet commented Jul 30, 2019

I think we'd almost certainly need something very similar! I'd propose to attach it to a context though.

SGTM. (we should probably make sure extracting informations and/or restoring state from that context.Context isn't showing abysmal performances, though.)

@ncw
Copy link
Collaborator

ncw commented Jul 30, 2019

SGTM. (we should probably make sure extracting informations and/or restoring state from that context.Context isn't showing abysmal performances, though.)

Hmm, yes! AFAICS context is implemented as linked list, so the lookup isn't very efficient.

@drew-512
Copy link
Contributor

I suggest to close this issue with the push of v0.1.0 (multi-context support)

@drew-512
Copy link
Contributor

drew-512 commented Feb 16, 2022

@yanchenghust v0.1.0 introduces py.Context which is the best-case scenario for concurrent interpreter execution while also aligned with Go programming patterns. For example:

for _, item := range items {
    go func() {
        ctx := py.NewContext(opts)
        ...
        setupState(ctx, item)
        py.Run*(ctx, ...)
        ...
        ctx.Close()
    }()
}

@sbinet
Copy link
Member

sbinet commented Feb 22, 2022

fixed w/ #158

@sbinet sbinet closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants