From 0a25dfb2e29be57d88396685950b38e5754bc5b2 Mon Sep 17 00:00:00 2001 From: owocki Date: Mon, 16 Mar 2020 11:21:26 -0600 Subject: [PATCH] abstracts away management of handling of timeout errors --- app/dashboard/notifications.py | 9 ++++++++- app/dashboard/views.py | 10 ++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/dashboard/notifications.py b/app/dashboard/notifications.py index 227b3ad4fff..4931afe83bc 100644 --- a/app/dashboard/notifications.py +++ b/app/dashboard/notifications.py @@ -256,8 +256,15 @@ def build_message_for_integration(bounty, event_name): f"\n{bounty.get_absolute_url()}" return msg -@timeout(2) + def maybe_market_to_user_slack(bounty, event_name): + try: + return maybe_market_to_user_slack_helper(bounty, event_name) + except TimeoutError as e: + logger.exception(e) + +@timeout(1) +def maybe_market_to_user_slack_helper(bounty, event_name): """Send a Slack message to the user's slack channel for the specified Bounty. Args: diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 4d626dd4497..7c1a078a5d3 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -1776,10 +1776,7 @@ def helper_handle_approvals(request, bounty): maybe_market_to_github(bounty, 'work_started', profile_pairs=bounty.profile_pairs) maybe_market_to_slack(bounty, 'worker_approved') - try: - maybe_market_to_user_slack(bounty, 'worker_approved') - except TimeoutError: - pass + maybe_market_to_user_slack(bounty, 'worker_approved') record_bounty_activity(bounty, request.user, 'worker_approved', interest) else: start_work_rejected(interest, bounty) @@ -1789,10 +1786,7 @@ def helper_handle_approvals(request, bounty): interest.delete() maybe_market_to_slack(bounty, 'worker_rejected') - try: - maybe_market_to_user_slack(bounty, 'worker_rejected') - except TimeoutError: - pass + maybe_market_to_user_slack(bounty, 'worker_rejected') messages.success(request, _(f'{worker} has been {mutate_worker_action_past_tense}')) else: