AshlinHarris / Spinners.jl

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

Spinners are not drawn interactively #100

Closed AshlinHarris closed 1 year ago

AshlinHarris commented 1 year ago

The spinner is drawn when the main thread is idle (as with sleep), but not when it is busy (as with any sort of task that actually needs a spinner).

Running julia -p 2 --threads 1,1 to get an interactive threadpool:

julia> using Spinners
julia> function some_long_calculations() 
       s=0
       for i in 10:17
               s += BigInt(999)^10_000_000 % 17
       end
       end
julia> usleep(usecs) = ccall(:usleep, Cint, (Cuint,), usecs)

julia> @spinner sleep(2)
# Works fine
julia> @spinner usleep(1_000_000)
# No spinner
julia> @spinner f()
# No spinner

Maybe stdout isn't being updated by the interactive thread? Honestly, the only workaround I've ever found was to shell out as a new process, but that stopped being stable on Windows.

AshlinHarris commented 1 year ago

Are interactive threadpools actually implemented yet, or just the API?

AshlinHarris commented 1 year ago

Maybe stdout just needs to be flushed.

AshlinHarris commented 1 year ago

usleep might not function on Windows

AshlinHarris commented 1 year ago

I suspect that the spinner thread is not being run in parallel.

AshlinHarris commented 1 year ago

105