Skip to content

Instantly share code, notes, and snippets.

@Iftimie
Created September 6, 2020 12:11
Show Gist options
  • Save Iftimie/7dd68e3beb9c715323defff78b4a5b40 to your computer and use it in GitHub Desktop.
Save Iftimie/7dd68e3beb9c715323defff78b4a5b40 to your computer and use it in GitHub Desktop.
def on_post(self, req, resp):
phrase_file = req.params['phrase_file']
...
trie_local_file_name = f"/app/assembler/triebuilder/shared_data/trie_{phrase_file}.dat"
pickle.dump(trie, open(trie_local_file_name, "wb"))
...
def _load_trie(self):
shared_path = "/app/distributor/backend/shared_data"
trie_files = sorted(os.listdir(shared_path))
if trie_files and trie_files[-1]!=self.trie_file:
self.trie = pickle.load( open(os.path.join(shared_path, trie_files[-1]), "rb"))
self.trie_file = trie_files[-1]
else:
self.trie = Trie()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment