Skip to content
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

Is it possible to work with multi-processing? #209

Open
1992leiting opened this issue Oct 18, 2023 · 4 comments
Open

Is it possible to work with multi-processing? #209

1992leiting opened this issue Oct 18, 2023 · 4 comments

Comments

@1992leiting
Copy link

Actor model is often used to build a MMO server. I just found Pykka easy to use. Is it possible to work with Python mutl-processing without much additional effort to take full advantage of multi-cores?

@jodal
Copy link
Owner

jodal commented Oct 19, 2023

I haven't looked into multiprocessing in a long time, but Pykka had support for gevent and eventlet as alternatives to threading until recently, so the flexibility to build multiprocessing support is there.

I should mention that with threading/gevent/eventlet there was no support for mixing and communicating across the different runtimes. I assume you don't want to run everything as its own process?

@1992leiting
Copy link
Author

I have a idea of gevent/eventlet but I did have a google search on how it works. I do not worry about IO intensive tasks but compute intensive ones. It will be great if actors in different processes can communicate to workaround Python GIL limitation and improve performance.

@jodal
Copy link
Owner

jodal commented Oct 20, 2023

I didn't intend for you to use gevent/eventlet, I just tried to point out that it should be fairly easy to make Pykka use processes instead of threads, just like it previously supported "green threads" instead of threads.

However, Pykka has never had support for mixing runtimes, e.g. having a group of actors running as threads in one process communicating with an actor in another process. That would probably require large changes to Pykka's APIs.

Thus, the realistic alternatives are to either:

  • Add support for multiprocessing as a Pykka "runtime" and run every actor as a separate process, or:
  • Use Pykka as-is with threads in each process and use other means to communicate between processes.

@coldwarrl
Copy link

coldwarrl commented Apr 22, 2024

Wouldn't disabling the GIL(python/cpython#116338) (I know it is still experimental) solve the issue, that is the actors would be able to run on different cores without any code changes ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants