Skip to content

Commit 4fa1228

Browse files
author
Christopher Doris
committed
test the gc queue is not empty while gil still unlocked
1 parent 2b0d376 commit 4fa1228

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/GC.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
@testitem "GC.gc()" begin
22
let
33
pyobjs = map(pylist, 1:100)
4-
PythonCall.GIL.@unlock Threads.@threads for obj in pyobjs
5-
finalize(obj)
4+
PythonCall.GIL.@unlock begin
5+
Threads.@threads for obj in pyobjs
6+
finalize(obj)
7+
end
8+
Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items)
69
end
710
end
8-
Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items)
911
PythonCall.GC.gc()
1012
@test isempty(PythonCall.GC.QUEUE.items)
1113
end
1214

1315
@testitem "GC.GCHook" begin
1416
let
1517
pyobjs = map(pylist, 1:100)
16-
PythonCall.GIL.@unlock Threads.@threads for obj in pyobjs
17-
finalize(obj)
18+
PythonCall.GIL.@unlock begin
19+
Threads.@threads for obj in pyobjs
20+
finalize(obj)
21+
end
22+
Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items)
1823
end
1924
end
20-
Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items)
2125
GC.gc()
2226
@test isempty(PythonCall.GC.QUEUE.items)
2327
end

0 commit comments

Comments
 (0)