From 242d9367239a0ff099e7a40acd7c0b02babb913e Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Tue, 10 Aug 2021 13:34:21 +0200 Subject: [PATCH] error will be thrown on expired hit. ignore --- exhausting_mturk/api.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/exhausting_mturk/api.py b/exhausting_mturk/api.py index a4c136c..8ddc8ae 100644 --- a/exhausting_mturk/api.py +++ b/exhausting_mturk/api.py @@ -98,19 +98,22 @@ class Connection(): logger.debug(f"Save {answer_filename}") json.dump(assignment, fp, cls=DateTimeEncoder, indent=4) - if not confirm("Accept input of worker (no = reject!!)", True) and confirm("Are you sure you want to reject this user?! (reason in next step)", False): - # reject - reason = input("Reason for rejection (no newlines)") - response = self.mturk.reject_assignment( - AssignmentId=assignment['AssignmentId'], - RequesterFeedback=reason - ) - else: - response = self.mturk.approve_assignment( - AssignmentId=assignment['AssignmentId'] - # RequesterFeedback=reason - ) - + try: + if not confirm("Accept input of worker (no = reject!!)", True) and confirm("Are you sure you want to reject this user?! (reason in next step)", False): + # reject + reason = input("Reason for rejection (no newlines)") + response = self.mturk.reject_assignment( + AssignmentId=assignment['AssignmentId'], + RequesterFeedback=reason + ) + else: + response = self.mturk.approve_assignment( + AssignmentId=assignment['AssignmentId'] + # RequesterFeedback=reason + ) + except Exception as e: + logger.danger("ignoring exception on accepting/rejecting assignment!") + logger.exception(e) # save with new status after all processing is succesfull with open(hit_file, 'w') as fp: