AshlinHarris / Spinners.jl

Command line spinners in Julia with Unicode support
MIT License
13 stars 1 forks source link

Spinner doesn't update if the main thread is busy. #59

Closed AshlinHarris closed 1 year ago

AshlinHarris commented 2 years ago

Replicate the error:

# It looks fine if the thread is sleeping:
@spinner sleep(4)

# Nothing updates if the main thread is busy:
do_some_calculations(x) = sum(map(i -> BigInt(999)^10_000_000 % i, 1:x))
@spinner x = do_some_calculations(10);

I had hoped that using interactive threads would avoid this issue. Previously, I had shelled out to avoid the issue, but sleeping Windows processes hang if they're interrupted. I don't want to go back to shelling out, but maybe using a timer makes this more stable.

If I can't figure it out, I'll ask about interactive threads on the Julia Slack or Discourse.

AshlinHarris commented 2 years ago

Actually, it looks like Julia should be started with something like julia --threads auto,1. I think there is no interactive thread by default.

https://docs.julialang.org/en/v1.9-dev/manual/multi-threading/#man-threadpools