-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compilation is non-blocking #25
Comments
Recompiling this way BTW is considered debug behaviour and should not be used in production, does this happen so often it throws your debug/local environment out of sync each time? Because if it happens 1/3 or 1/10 times, thats OK for something not meant to be used in production. The correct way to hotload in production so everything stays in sync is to use releases. Adding this would be complex but something using https://www.erlang.org/doc/man/erlang.html#suspend_process-2 could work. Figure out which processes are critical to not suspend, spawn a "suspender" process, suspend all, recompile, resume. I think you could even code this yourself in minimal time :erlang.spawn(fn()->
me = self()
pids = :erlang.processes() -- [me]
pids |> Enum.each(& :erlang.suspend_process(&1))
recompile
pids |> Enum.each(& :erlang.resume_process(&1))
end) |
Yes, it's debug so it is not a big problem, but it happens often as I run some code over a big chunk of semistructured data using different rules and to do this I run the same function with just [Arrow up - Enter] in the console, so it is almost always faster than compilation. |
If you issue a Also what about |
|
looks like something like this does the job Me = self(),
F = fun() ->
erlang:display(start),
Pid = shell:whereis(),
erlang:suspend_process(Pid),
try
rebar_agent:do(compile)
after
erlang:resume_process(Pid)
end,
erlang:display('end'),
Me ! done
end,
spawn(F),
receive
done -> ok
end. |
Sometimes it takes several seconds to compile changed modules. This compilation is asynchronous so it won't lock console prompt thus it is possible to call a function which still would use code from the old version of a module, opaque to the user. There's even no indication whether the process of compilation and changing of code has been completed or not. Is it possible to make compilation synchronous and lock the console until the compilation process is completed?
The text was updated successfully, but these errors were encountered: