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

Support for Multi-Threading with PythonCall? #330

Closed
nic-barbara opened this issue Jun 28, 2023 · 3 comments
Closed

Support for Multi-Threading with PythonCall? #330

nic-barbara opened this issue Jun 28, 2023 · 3 comments
Labels
enhancement New feature or request stale Issues about to be auto-closed

Comments

@nic-barbara
Copy link

Are there any plans to support multi-threading with PythonCall.jl in the near future? Almost everything about this package is superior to PyCall.jl except for thread safety.

Specifically, it would be great (and in my case - is essential) to be able to call python functions on many threads in parallel. This is useful when a core routine is written in python and needs to be called many time independently.

For example, some environments in ReinforcementLearning.jl rely on the python bindings to MuJoCo. Evaluating these environments efficiently requires multi-threading (eg: this implementation with PyCall.jl), which is currently impossible in PythonCall.

Is this something you would consider supporting in the near future?

@github-actions
Copy link
Contributor

This issue has been marked as stale because it has been open for 30 days with no activity. If the issue is still relevant then please leave a comment, or else it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues about to be auto-closed label Aug 19, 2023
@cjdoris
Copy link
Collaborator

cjdoris commented Aug 19, 2023

Because of the GIL, Python itself has poor support for multithreading, because only one thread can hold the GIL at a time, and this is required to do anything Pythonic. Hence multithreading is only useful in Python if you are doing a lot of work which can release the GIL (such as IO or long-running numerical routines written in C).

In general, if you want to parallelise Python it's generally better to use multiprocessing instead of multithreading. So there are no plans for PythonCall to support it.

@github-actions github-actions bot removed the stale Issues about to be auto-closed label Aug 20, 2023
@github-actions
Copy link
Contributor

Thank you for taking the time to report this issue!
However, it has been marked as stale because there has been no activity for 30 days. As with many open source projects, the maintainers work for free and do not always have enough time to address all issues.
For questions, please check the documentation, other issues, or consider asking elsewhere such as Stack Overflow or Julia Discourse. For bugs, please try to find a fix yourself and consider opening a pull request. If you're still stuck, please leave a comment below.
If there is no further activity in 7 days, this issue will be automatically closed.

@github-actions github-actions bot added the stale Issues about to be auto-closed label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Issues about to be auto-closed
Projects
None yet
Development

No branches or pull requests

2 participants