Browse Source

Improve borg process spawning and result checking

master
Jim Paris 7 months ago
parent
commit
46195daaaa
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      backup.py

+ 14
- 3
backup.py View File

@@ -9,6 +9,7 @@ import os
import re
import sys
import stat
import time
import pathlib
import subprocess

@@ -254,9 +255,19 @@ def main(argv: list[str]):
stdin=subprocess.PIPE)
if borg.stdin is None:
raise Exception("no pipe")
backup.run(borg.stdin)
borg.stdin.close()
ret = borg.wait()
try:
# Give borg some time to start, just to clean up stdout
time.sleep(2)
backup.run(borg.stdin)
except BrokenPipeError:
sys.stderr.write(f"broken pipe\n")
finally:
try:
borg.stdin.close()
except BrokenPipeError:
pass
borg.wait()
ret = borg.returncode
if ret < 0:
sys.stderr.write(f"error: process exited with signal {-ret}\n")
return 1


Loading…
Cancel
Save