]> arthur.ath.cx Git - bup.git/blobdiff - lib/bup/cmd/server.py
Context manage connections (via BaseConn)
[bup.git] / lib / bup / cmd / server.py
index 3d077dd65d90a7e0253f1c10fa2352883a4a670c..b4f047271858b054d936e2174b00446dec7fe3e5 100755 (executable)
@@ -301,10 +301,10 @@ def main(argv):
     # FIXME: this protocol is totally lame and not at all future-proof.
     # (Especially since we abort completely as soon as *anything* bad happens)
     sys.stdout.flush()
-    conn = Conn(byte_stream(sys.stdin), byte_stream(sys.stdout))
-    lr = linereader(conn)
-    with finalized(None, lambda _: repo and repo.close()), \
+    with Conn(byte_stream(sys.stdin), byte_stream(sys.stdout)) as conn, \
+         finalized(None, lambda _: repo and repo.close()), \
          finalized(None, lambda _: suspended_w and suspended_w.close()):
+        lr = linereader(conn)
         for _line in lr:
             line = _line.strip()
             if not line: