Recently I encountered the following error while developing my experimental Grassmann.jl package
The following error only occurs if I run the commands at once using ;
on one line
julia> using Grassmann; mixedbasis"2"
[ Info: Allocating thread-safe 16×Basis{VectorSpace{4,0,0,12}*,...}
┌ Error: Exception while generating log record in module Grassmann at /home/flow/.julia/dev/Grassmann/src/Grassmann.jl:136
│ exception =
│ task switch not allowed from inside staged nor pure functions
│ Stacktrace:
│ [1] unsafe_write(::Base.TTY, ::Ptr{UInt8}, ::UInt64) at ./stream.jl:830
│ [2] macro expansion at ./io.jl:509 [inlined]
│ [3] write(::Base.TTY, ::Array{UInt8,1}) at ./io.jl:532
│ [4] #handle_message#2(::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Logging.ConsoleLogger, ::Base.CoreLogging.LogLevel, ::String, ::Module, ::String, ::Symbol, ::String, ::Int64) at /build/julia/src/julia-1.0.3/usr/share/julia/stdlib/v1.0/Logging/src/ConsoleLogger.jl:161
│ [5] handle_message(::Logging.ConsoleLogger, ::Base.CoreLogging.LogLevel, ::String, ::Module, ::String, ::Symbol, ::String, ::Int64) at /build/julia/src/julia-1.0.3/usr/share/julia/stdlib/v1.0/Logging/src/ConsoleLogger.jl:100
│ [6] getalgebra(::Int64, ::Int64, ::UInt64) at ./logging.jl:320
│ [7] @mixedbasis_str(::LineNumberNode, ::Module, ::Any) at /home/flow/.julia/dev/Grassmann/src/multivectors.jl:212
└ @ Grassmann ~/.julia/dev/Grassmann/src/Grassmann.jl:136
Exception handling log message:
(++--*, v, v₁, v₂, w¹, w², v₁₂, v₁w¹, v₁w², v₂w¹, v₂w², w¹², v₁₂w¹, v₁₂w², v₁w¹², v₂w¹², v₁₂w¹²)
otherwise, if I first run using Grassmann
and then mixedbasis"2"
afterwards, there is no issue.
This is likely because the REPL is doing some task switching due to the combined input.
What can I do about this issue? As far as I can tell, the error message does not affect the actual Julia session, and the result of the mixedbasis"2"
command is returned after the error message.
This is an error which only takes place in some other REPL scope, but not in the program execution.
Now, I know some people might suggest that I should not be using @pure
methods in certain contexts; however, I am having success with them if they are used safely. It is my choice to work with it and I don’t intend to change my design currently only to solve this one particular case.
Is there some way to disable the logging which causes this error? What’s exactly going on here, would be useful to know more details about how the error occurs.