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,38 +353,28 @@ 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:
import time
from ._ledger import open_trade_ledger
if not ledger: now = time.time()
import time
from tractor._debug import open_crash_handler
from ._ledger import open_trade_ledger
now = time.time() with open_trade_ledger(
with ( brokername,
open_crash_handler(), acctname,
rewrite=True,
allow_from_sync_code=True,
open_trade_ledger( # proxied through from caller
brokername, **kwargs,
acctname,
rewrite=True,
allow_from_sync_code=True,
# proxied through from caller ) as ledger:
**kwargs, if not ledger:
raise ValueError(f'No ledger for {acctname}@{brokername} exists?')
) as ledger, print(f'LEDGER LOAD TIME: {time.time() - now}')
):
if not ledger:
raise ValueError(f'No ledger for {acctname}@{brokername} exists?')
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