# HG changeset patch # User wenzelm # Date 1695731395 -7200 # Node ID 89038d9ef77d8f595c4a3a5a3bb7b329a673045a # Parent f34a451f7b5b63f88d0e5320a0d1a4f7ff2aaae1 more robust management of resources, using Thread_Attributes.uninterruptible; diff -r f34a451f7b5b -r 89038d9ef77d src/Pure/ML/ml_compiler0.ML --- a/src/Pure/ML/ml_compiler0.ML Tue Sep 26 13:37:08 2023 +0200 +++ b/src/Pure/ML/ml_compiler0.ML Tue Sep 26 14:29:55 2023 +0200 @@ -117,11 +117,12 @@ end; -fun ML_file context {verbose, debug} file = +fun ML_file context {verbose, debug} file = Thread_Attributes.uninterruptible (fn run => fn () => let val instream = TextIO.openIn file; - val text = Exn.release (Exn.capture TextIO.inputAll instream before TextIO.closeIn instream); - in ML context {line = 1, file = file, verbose = verbose, debug = debug} text end; + val result = Exn.capture (run TextIO.inputAll) instream; + val _ = TextIO.closeIn instream; + in ML context {line = 1, file = file, verbose = verbose, debug = debug} (Exn.release result) end) (); fun ML_file_operations (f: bool option -> string -> unit) = {ML_file = f NONE, ML_file_debug = f (SOME true), ML_file_no_debug = f (SOME false)}; diff -r f34a451f7b5b -r 89038d9ef77d src/Pure/System/isabelle_system.ML --- a/src/Pure/System/isabelle_system.ML Tue Sep 26 13:37:08 2023 +0200 +++ b/src/Pure/System/isabelle_system.ML Tue Sep 26 14:29:55 2023 +0200 @@ -149,9 +149,13 @@ fun rm_tree path = scala_function "rm_tree" [path]; -fun with_tmp_dir name f = - let val path = create_tmp_path name "" - in Exn.release (Exn.capture f (make_directory path) before ignore (try rm_tree path)) end; +fun with_tmp_dir name f = Thread_Attributes.uninterruptible (fn run => fn () => + let + val path = create_tmp_path name ""; + val _ = make_directory path; + val result = Exn.capture (run f) path; + val _ = try rm_tree path; + in Exn.release result end) (); (* download file *)