julia
b029fbfe - Wait for all tasks before writing precompile files (#46571)

Commit
3 years ago
Wait for all tasks before writing precompile files (#46571) When the program goes to write out a precompile file, we would like for the process to first reach a point where it is not still running background tasks and work. This ensures that the precompile file is in a consistent state, and isn't forgetting or delaying intended work. In the future, we may want to add an `atexit` hook (after the other `atexit` hooks) which optionally calls this function for regular code too, probably under programmatic control and/or command line argument control for the user to decide. And we would need to decide how to close stdin first, so it doesn't continue to keep the program alive. Add uv_ref and uv_unref internal hooks for this. You probably really don't want to call these (as they may stop you from getting events on these objects also), but very specific internal things will need them for this to work. Also (mostly unrelated) rewrite a Profile test to conform to best-practices. Previously, the loop was expecting to observe the Profile test printing even though nothing kept it alive (there was no reads on stdin). We fix the design of that test, but also include a patch inside `jl_process_events` to ensure the loop is alive and will handle events, to avoid breaking anyone else who was relying on this pattern. To assist package authors fix errors, we automatically print a note if this new functionality is causing delays. They then need to ensure they are calling close explicitly (not relying solely on finalizers), when appropriate, and are cleaning up other resources (or calling the new `Base.uv_unref`) also. Fix #45170
Author
Parents
Loading