From 930bf099a3f0cf9bcaf2d1838fda953c63e6d704 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Fri, 16 Nov 2018 22:33:51 +0000 Subject: [PATCH] Attempt to fix issue with slow unpickling.. --- location/__init__.py | 9 +++++---- location/__main__.py | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/location/__init__.py b/location/__init__.py index 7d3eac8..02d0e20 100644 --- a/location/__init__.py +++ b/location/__init__.py @@ -63,10 +63,12 @@ def load_locations() -> Iterator[Location]: ) def iter_locations(cached: bool=False) -> Iterator[Location]: - import dill # type: ignore + import sys + sys.path.append('/L/Dropbox/data/location_provider') # jeez.. otherwise it refuses to unpickle :( + + import pickle as dill # type: ignore if cached: with open(CACHE_PATH, 'rb') as fo: - # TODO while fo has more data? while True: try: pre = dill.load(fo) @@ -168,9 +170,8 @@ def get_groups(cached: bool=False) -> List[LocInterval]: dump_group() return groups -# TODO ok, def cache groups. def update_cache(): - import dill # type: ignore + import pickle as dill # type: ignore CACHE_PATH_TMP = CACHE_PATH + '.tmp' # TODO maybe, also keep on /tmp first? with open(CACHE_PATH_TMP, 'wb', 2 ** 20) as fo: diff --git a/location/__main__.py b/location/__main__.py index 6eed9db..b085a61 100644 --- a/location/__main__.py +++ b/location/__main__.py @@ -18,6 +18,5 @@ if len(sys.argv) > 1: raise RuntimeError(f"Unknown command {cmd}") else: for p in get_groups(cached=True): - pass + print(p) # TODO need datetime! - # print(p)