import json def dump_message_list( messages, path="", ): with open(path + ".messages", "w+") as f: for msg in messages: f.write(msg + "\n") with open(path + ".dag_run_id", "w+") as f: for msg in messages: f.write(json.loads(msg)["dag_run_id"] + "\n")