Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 56aa9bc

Browse files
author
Christopher Doris
committedAug 1, 2024
update docs
1 parent 4b3bd65 commit 56aa9bc

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed
 

‎docs/src/faq.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44

55
No.
66

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)
2024

2125
## Issues when Numpy arrays are expected
2226

‎docs/src/releasenotes.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Release Notes
22

3+
## Unreleased
4+
* Finalizers are now thread-safe, meaning PythonCall now works in the presence of
5+
multi-threaded Julia code. Previously, tricks such as disabling the garbage collector
6+
were required. Python code must still be called on the main thread.
7+
* `GC.disable()` and `GC.enable()` are now a no-op and deprecated since they are no
8+
longer required for thread-safety. These will be removed in v1.
9+
* Adds `GC.gc()`.
10+
311
## 0.9.21 (2024-07-20)
412
* `Serialization.serialize` can use `dill` instead of `pickle` by setting the env var `JULIA_PYTHONCALL_PICKLE=dill`.
513
* `numpy.bool_` can now be converted to `Bool` and other number types.

‎src/GC/GC.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Garbage collection of Python objects.
55
6-
See [`enable`](@ref), [`disable`](@ref) and [`gc`](@ref).
6+
See [`gc`](@ref).
77
"""
88
module GC
99

0 commit comments

Comments
 (0)
Please sign in to comment.