-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathGC.jl
More file actions
37 lines (33 loc) · 994 Bytes
/
GC.jl
File metadata and controls
37 lines (33 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using TestItemRunner
@testitem "GC.gc()" begin
using PythonCall
let
pyobjs = map(pylist, 1:100)
PythonCall.GIL.@unlock Threads.@threads for obj in pyobjs
finalize(obj)
end
end
Threads.nthreads() > 1 &&
VERSION >= v"1.10.0-" &&
@test !isempty(PythonCall.GC.QUEUE.items)
PythonCall.GC.gc()
@test isempty(PythonCall.GC.QUEUE.items)
end
@testitem "GC.GCHook" begin
using PythonCall
let
pyobjs = map(pylist, 1:100)
PythonCall.GIL.@unlock Threads.@threads for obj in pyobjs
finalize(obj)
end
end
Threads.nthreads() > 1 &&
VERSION >= v"1.10.0-" &&
@test !isempty(PythonCall.GC.QUEUE.items)
GC.gc()
# Unlock and relocking the ReentrantLock allows this test to pass
# if _jl_gil_lock is locked on init
# Base.unlock(PythonCall.GIL._jl_gil_lock)
# Base.lock(PythonCall.GIL._jl_gil_lock)
@test isempty(PythonCall.GC.QUEUE.items)
end