Skip to content

Commit

Permalink
use try since write will fail on aws lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
ericz1803 committed Nov 15, 2023
1 parent 6c5239a commit 3e51f03
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions capitoltrades/CapitolTrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ def update_data(self):
print(f"Merged {len(new_data)} new records and {len(self.data)} old records into {len(merged_data)} total records.")

script_dir = os.path.dirname(__file__)
with open(os.path.join(script_dir, self.__pkl_path), "wb") as fp:
pickle.dump(merged_data, fp)
try:
with open(os.path.join(script_dir, self.__pkl_path), "wb") as fp:
pickle.dump(merged_data, fp)
except Exception as e:
logging.error("Error saving pickle file: " + str(e))

self.data = merged_data

0 comments on commit 3e51f03

Please sign in to comment.