@@ -143,14 +143,22 @@ function main(dummyargs...)
143
143
try
144
144
_, cols = displaysize (stdout )
145
145
t1 = @async begin
146
- plts = []
147
- append! (plts, plot_cpu_utilization_rates (CPUDevice))
148
- n = max (1 , cols ÷ 25 )
149
- chunks = collect (Iterators. partition (plts, n))
150
- f = foldl (/ , map (c -> prod (UnicodePlots. panel .(c)), chunks))
151
-
152
- f /= prod (UnicodePlots. panel .(plot_cpu_memory_utilization (CPUDevice)))
153
- f
146
+ try
147
+ plts = []
148
+ append! (plts, plot_cpu_utilization_rates (CPUDevice))
149
+ n = max (1 , cols ÷ 25 )
150
+ chunks = collect (Iterators. partition (plts, n))
151
+ f = foldl (/ , map (c -> prod (UnicodePlots. panel .(c)), chunks))
152
+
153
+ f /= prod (UnicodePlots. panel .(plot_cpu_memory_utilization (CPUDevice)))
154
+ return f
155
+ catch e
156
+ if e isa InterruptException
157
+ return nothing
158
+ else
159
+ rethrow (e)
160
+ end
161
+ end
154
162
end
155
163
156
164
if isdefined (Main, :CUDA ) &&
@@ -167,16 +175,39 @@ function main(dummyargs...)
167
175
end
168
176
gpuchunks = collect (Iterators. partition (cudaplts, n))
169
177
f /= foldl (/ , map (c -> prod (UnicodePlots. panel .(c)), gpuchunks))
170
- elseif isdefined (Main, :Metal ) && Sys. isapple () && Sys. ARCH == :aarch64
178
+ elseif isdefined (Main, :MacOSIOReport ) && Sys. isapple () && Sys. ARCH == :aarch64
171
179
metalplts = []
172
180
n = max (1 , cols ÷ 50 )
173
- t2 = @async plot_cpu_utilization_rates (MetalDevice)
174
- t3 = @async plot_gpu_utilization_rates (MetalDevice)
181
+ t2 = @async begin
182
+ try
183
+ return plot_cpu_utilization_rates (MetalDevice)
184
+ catch e
185
+ if e isa InterruptException
186
+ return nothing
187
+ else
188
+ rethrow (e)
189
+ end
190
+ end
191
+ end
192
+ t3 = @async begin
193
+ try
194
+ return plot_gpu_utilization_rates (MetalDevice)
195
+ catch e
196
+ if e isa InterruptException
197
+ return nothing
198
+ else
199
+ rethrow (e)
200
+ end
201
+ end
202
+ end
175
203
wait (t1)
176
204
wait (t2)
177
205
wait (t3)
178
206
plts1 = fetch (t2)
179
207
plts2 = fetch (t3)
208
+ if isnothing (plts1) || isnothing (plts2)
209
+ break
210
+ end
180
211
for i in eachindex (plts1)
181
212
push! (metalplts, plts1[i])
182
213
end
@@ -188,21 +219,18 @@ function main(dummyargs...)
188
219
else
189
220
wait (t1)
190
221
f = fetch (t1)
222
+ if isnothing (f)
223
+ break
224
+ end
191
225
end
192
226
clearlinesall ()
193
227
display (f)
194
228
catch e
195
229
unhidecursor () # unhide cursor
196
- if e isa InterruptException || e isa TaskFailedException
197
- @info " Intrrupted"
198
- break
199
- else
200
- @warn " Got Exception"
201
- rethrow (e) # so we don't swallow true exceptions
202
- end
230
+ @warn " Got Exception"
231
+ rethrow (e) # so we don't swallow true exceptions
203
232
end
204
233
end
205
- @info " Unhide cursor"
206
234
unhidecursor () # unhide cursor
207
235
end
208
236
0 commit comments