From 9474c441711dbf7bf1ec0940c7e194c892fc7fcc Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Wed, 29 Mar 2023 09:21:06 +0000 Subject: [PATCH] Ensure that FD 3 gets closed It appears that Python doesn't reliably (or maybe just doesn't at all) flush and close non-standard FDs on exit. This randomly caused the artefacts list to get lost to /dev/null. --- codearchiver/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codearchiver/cli.py b/codearchiver/cli.py index b115e9d..2d05cd0 100644 --- a/codearchiver/cli.py +++ b/codearchiver/cli.py @@ -206,8 +206,9 @@ def main(): if args.writeArtefactsFd3: with storage.lock(): artefacts = storage.list_new_files() - for filename in artefacts: - print(filename, file = artefactsFd) + with artefactsFd: + for filename in artefacts: + print(filename, file = artefactsFd) if __name__ == '__main__': main()