From 3dcb72d429ebb1c474ce300b3204541eb7044d5f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 16 Jun 2022 10:52:43 -0400 Subject: [PATCH] Only finally-write around the ledger yield up --- piker/pp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/piker/pp.py b/piker/pp.py index a3aab3d5..a6f61f56 100644 --- a/piker/pp.py +++ b/piker/pp.py @@ -69,11 +69,11 @@ def open_trade_ledger( ) with open(tradesfile, 'w') as cf: pass # touch + with open(tradesfile, 'r') as cf: + ledger = toml.load(tradesfile) + cpy = ledger.copy() try: - with open(tradesfile, 'r') as cf: - ledger = toml.load(tradesfile) - cpy = ledger.copy() - yield cpy + yield cpy finally: if cpy != ledger: # TODO: show diff output?