Skip to content

Commit

Permalink
abstracts away management of handling of timeout errors
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Mar 16, 2020
1 parent 69f4f93 commit 0a25dfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 8 additions & 1 deletion app/dashboard/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 2 additions & 8 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 0a25dfb

Please sign in to comment.