Skip to content

Commit 44435c2

Browse files
authored
Merge pull request #69 from JuliaData/jps/evict-no-cpuramdevice
exit_hook: Ignore CPURAMDevice
2 parents da2cbd4 + 2016201 commit 44435c2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: src/MemPool.jl

+13-2
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,28 @@ function __init__()
122122
end
123123
function exit_hook()
124124
exit_flag[] = true
125+
125126
evict_delay = DISKCACHE_CONFIG[].evict_delay
126127
kill_counter = evict_delay
128+
129+
function datastore_empty(do_lock=true)
130+
with_lock(datastore_lock, do_lock) do
131+
all(ref->storage_read(ref).root isa CPURAMDevice, values(datastore))
132+
end
133+
end
134+
135+
# Wait for datastore objects to naturally expire
127136
GC.gc()
128137
yield()
129-
while kill_counter > 0 && with_lock(()->!isempty(datastore), datastore_lock)
138+
while kill_counter > 0 && !datastore_empty()
130139
GC.gc()
131140
sleep(1)
132141
kill_counter -= 1
133142
end
143+
144+
# Forcibly evict remaining objects
134145
with_lock(datastore_lock) do
135-
if length(datastore) > 0
146+
if !datastore_empty(false)
136147
@debug "Failed to cleanup datastore after $evict_delay seconds\nForcibly evicting all entries"
137148
for id in collect(keys(datastore))
138149
state = MemPool.datastore[id]

0 commit comments

Comments
 (0)