<div dir="ltr"><div dir="ltr">Norbert wrote:</div><div dir="ltr"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
It happens very rarely, we already try to ensure that writes are done on a<br>
per package basis, and fs are synced afterwards. Having a completely safe<br>
against interrupts implementation would be nice, but would require developing<br>
some journaling for tlmgr operations, which we don't have.<br></blockquote><div><br></div><div>This statement is helpful. I have one additional comment. It may be that adding sufficient "journaling for tlmgr operations" would be practical, and in particular not too hard.<br></div></div><div class="gmail_quote"><br></div><div class="gmail_quote">The tlmgr is written in Perl. If Python were used, a 'with statement context manager' would in my opinion solve most or all the problems of file writes failing and so needing a cleanup. I wonder, is there something similar in Perl?</div><div class="gmail_quote"><br></div><div class="gmail_quote">There's documentation of the Python "with" statement at:</div><div class="gmail_quote"><a href="https://peps.python.org/pep-0343/">https://peps.python.org/pep-0343/</a></div><div class="gmail_quote"><a href="https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers">https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers</a></div><div class="gmail_quote"><br></div><div class="gmail_quote">The basic idea is that</div><div class="gmail_quote"> with manager(parameters) as mgr:</div><div class="gmail_quote"> do_something_using(mgr)</div><div class="gmail_quote">means</div><div class="gmail_quote"><br></div><div class="gmail_quote">1. obj = manager(parameter) has __enter__ and __exit__ methods.</div><div class="gmail_quote">2. mgr is given the value of obj.__enter__().</div><div class="gmail_quote">3. Upon exiting the with statement, either normally or with an exception, obj.__exit(...) is called.</div><div class="gmail_quote">4. The obj.__exit__(...) has as parameter either None or the exception (if there is one).</div><div class="gmail_quote">5. After obj.__exit__(...) is done, the "with" statement will reraise the exception (if there is one).<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">The obj.__exit(...) method should at the very least close file handles, release other resources. For tlmgr, we'd like it to do any cleanup required to produce a consistent state on disk. If I'm correct, this will be sufficient for solving (or at least substantially improving) the present situation with tlmgr. In my opinion, this would provide sufficient "journaling for tlmgr operations".</div><div class="gmail_quote"><br></div><div class="gmail_quote">I think it would be most helpful if Perl has something similar to the Python "with" statement. Hence my asking if Perl has such.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">-- <br></div><div class="gmail_quote">Jonathan<br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div></div>