|
4 | 4 |
|
5 | 5 | No.
|
6 | 6 |
|
7 |
| -Some rules if you are writing multithreaded code: |
8 |
| -- Only call Python functions from the first thread. |
9 |
| -- You probably also need to call `PythonCall.GC.disable()` on the main thread before any |
10 |
| - threaded block of code. Remember to call `PythonCall.GC.enable()` again afterwards. |
11 |
| - (This is because Julia finalizers can be called from any thread.) |
12 |
| -- Julia intentionally causes segmentation faults as part of the GC safepoint mechanism. |
13 |
| - If unhandled, these segfaults will result in termination of the process. To enable signal handling, |
14 |
| - set `PYTHON_JULIACALL_HANDLE_SIGNALS=yes` before any calls to import juliacall. This is equivalent |
15 |
| - to starting julia with `julia --handle-signals=yes`, the default behavior in Julia. |
16 |
| - See discussion [here](https://github.com/JuliaPy/PythonCall.jl/issues/219#issuecomment-1605087024) for more information. |
17 |
| -- You may still encounter problems. |
18 |
| - |
19 |
| -Related issues: [#201](https://github.com/JuliaPy/PythonCall.jl/issues/201), [#202](https://github.com/JuliaPy/PythonCall.jl/issues/202) |
| 7 | +However it is safe to use PythonCall with Julia with multiple threads, provided you only |
| 8 | +call Python code from the first thread. (Before v0.9.22, tricks such as disabling the |
| 9 | +garbage collector were required.) |
| 10 | + |
| 11 | +From Python, to use JuliaCall with multiple threads you probably need to set |
| 12 | +[`PYTHON_JULIACALL_HANDLE_SIGNALS=yes`](@ref julia-config) before importing JuliaCall. |
| 13 | +This is because Julia intentionally causes segmentation faults as part of the GC |
| 14 | +safepoint mechanism. If unhandled, these segfaults will result in termination of the |
| 15 | +process. This is equivalent to starting julia with `julia --handle-signals=yes`, the |
| 16 | +default behavior in Julia. See discussion |
| 17 | +[here](https://github.com/JuliaPy/PythonCall.jl/issues/219#issuecomment-1605087024) |
| 18 | +for more information. |
| 19 | + |
| 20 | +Related issues: |
| 21 | +[#201](https://github.com/JuliaPy/PythonCall.jl/issues/201), |
| 22 | +[#202](https://github.com/JuliaPy/PythonCall.jl/issues/202), |
| 23 | +[#529](https://github.com/JuliaPy/PythonCall.jl/pull/529) |
20 | 24 |
|
21 | 25 | ## Issues when Numpy arrays are expected
|
22 | 26 |
|
|
0 commit comments