Lul, fix `open_ledger_dfs()` to `yield` when ledger passed in..

account_tests
Tyler Goodlet 2023-08-03 17:27:26 -04:00
parent 60751acf85
commit e4ea7d6193
1 changed files with 17 additions and 27 deletions

View File

@ -353,17 +353,15 @@ def open_ledger_dfs(
can update the ledger on exit. can update the ledger on exit.
''' '''
from tractor._debug import open_crash_handler
with open_crash_handler():
if not ledger: if not ledger:
import time import time
from tractor._debug import open_crash_handler
from ._ledger import open_trade_ledger from ._ledger import open_trade_ledger
now = time.time() now = time.time()
with (
open_crash_handler(),
open_trade_ledger( with open_trade_ledger(
brokername, brokername,
acctname, acctname,
rewrite=True, rewrite=True,
@ -372,20 +370,12 @@ def open_ledger_dfs(
# proxied through from caller # proxied through from caller
**kwargs, **kwargs,
) as ledger, ) as ledger:
):
if not ledger: if not ledger:
raise ValueError(f'No ledger for {acctname}@{brokername} exists?') raise ValueError(f'No ledger for {acctname}@{brokername} exists?')
print(f'LEDGER LOAD TIME: {time.time() - now}') print(f'LEDGER LOAD TIME: {time.time() - now}')
# process raw TOML ledger into txns using the
# appropriate backend normalizer.
# cache: AssetsInfo = get_symcache(
# brokername,
# allow_reload=True,
# )
yield ledger_to_dfs(ledger), ledger yield ledger_to_dfs(ledger), ledger