dmolina / DaemonMode.jl

Client-Daemon workflow to run faster scripts in Julia
MIT License
275 stars 16 forks source link

Add SIGINT handler? #47

Closed adigitoleo closed 2 years ago

adigitoleo commented 2 years ago

Thanks for the package, I'll need to read through more to understand it all.

One idea is that it could be convenient to handle SIGINT. Currently we have to press ^C twice to kill the server and it's a bit noisy:

%zsh: jl --startup-file=no -e 'using DaemonMode; serve()'
^CUnhandled Task ERROR: InterruptException:
Stacktrace:
 [1] poptask(W::Base.InvasiveLinkedListSynchronized{Task})
   @ Base ./task.jl:827
 [2] wait()
   @ Base ./task.jl:836
 [3] wait(c::Base.GenericCondition{ReentrantLock})
   @ Base ./condition.jl:123
 [4] #134
   @ /usr/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:281 [inlined]
 [5] lock(f::Distributed.var"#134#136", l::ReentrantLock)
   @ Base ./lock.jl:190
 [6] lock
   @ ./condition.jl:78 [inlined]
 [7] macro expansion
   @ /usr/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:279 [inlined]
 [8] (::Distributed.var"#133#135")()
   @ Distributed ./threadingconstructs.jl:178
^Cfatal: error thrown and no exception handler available.
InterruptException()
jl_mutex_unlock at /buildworker/worker/package_linux64/build/src/julia_locks.h:129 [inlined]
jl_task_get_next at /buildworker/worker/package_linux64/build/src/partr.c:484
poptask at ./task.jl:827
wait at ./task.jl:836
task_done_hook at ./task.jl:544
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_finish_task at /buildworker/worker/package_linux64/build/src/task.c:218
start_task at /buildworker/worker/package_linux64/build/src/task.c:888
adigitoleo commented 2 years ago

Oops it's a duplicate of #41