-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* slightly more thread safe gc * use Channel not Vector and make disable/enable a no-op * document GCHook * cannot lock channels on julia 1.6 * revert to using a vector for the queue * restore test script * combine queue into a single item * prefer Fix2 over anonymous function * update docs * test multithreaded * test gc from python * add gc tests * fix test * add deprecation warnings * safer locking (plus explanatory comments) * ref of weakref * SpinLock -> ReentrantLock * SpinLock -> ReentrantLock * typo: testset -> testitem * delete redundant test * remove out of date comment * comment erroneous test --------- Co-authored-by: Christopher Doris <github.com/cjdoris>
- Loading branch information
Showing
8 changed files
with
188 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
# TODO | ||
@testitem "GC.gc()" begin | ||
let | ||
pyobjs = map(pylist, 1:100) | ||
Threads.@threads for obj in pyobjs | ||
finalize(obj) | ||
end | ||
end | ||
# The GC sometimes actually frees everything before this line. | ||
# We can uncomment this line if we GIL.@release the above block once we have it. | ||
# Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items) | ||
PythonCall.GC.gc() | ||
@test isempty(PythonCall.GC.QUEUE.items) | ||
end | ||
|
||
@testitem "GC.GCHook" begin | ||
let | ||
pyobjs = map(pylist, 1:100) | ||
Threads.@threads for obj in pyobjs | ||
finalize(obj) | ||
end | ||
end | ||
# The GC sometimes actually frees everything before this line. | ||
# We can uncomment this line if we GIL.@release the above block once we have it. | ||
# Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items) | ||
GC.gc() | ||
@test isempty(PythonCall.GC.QUEUE.items) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using PythonCall | ||
|
||
# This would consistently segfault pre-GC-thread-safety | ||
let | ||
pyobjs = map(pylist, 1:100) | ||
Threads.@threads for obj in pyobjs | ||
finalize(obj) | ||
end | ||
end |