From 51674a0f55116afd6bb985fd0cf1dd25a6bd00a1 Mon Sep 17 00:00:00 2001 From: Mark Wunsch Date: Wed, 3 Aug 2016 09:11:39 -0400 Subject: [PATCH] Thread s3 uploading with twitter posting Await the completion of both operations --- src/sonic_sketches/core.clj | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sonic_sketches/core.clj b/src/sonic_sketches/core.clj index 2b36389..6323c15 100644 --- a/src/sonic_sketches/core.clj +++ b/src/sonic_sketches/core.clj @@ -311,12 +311,16 @@ :day-of-week day-of-week :iso8601 iso8601})] (logger/info "Finished recording to" recorded-to "🎶") - (try (upload-to-s3 bucket recorded-to metadata) - (catch Exception e (logger/fatal "Error uploading to s3" - (.getMessage e)))) - (try (twitter/tweet recorded-to metadata) - (catch Exception e (logger/fatal "Error posting to Twitter" - (.getMessage e)))) + (->> (vector (async/go (try (upload-to-s3 bucket recorded-to metadata) + (catch Exception e (logger/fatal "Error uploading to s3" + (.getMessage e))))) + (async/go (logger/info "Posting" recorded-to "to Twitter") + (try (twitter/tweet recorded-to metadata) + (catch Exception e (logger/fatal "Error posting to Twitter" + (.getMessage e)))))) + async/merge + (async/into []) + async/