def expire_and_dispose_hits(client: MTurkClient, hits: List[Dict[str, Any]], quiet: bool = False) -> List[Dict[str, Any]]: """ Loops over attempting to expire and dispose any hits in the hits list that can be disposed Returns any HITs that could not be disposed of """ non_disposed_hits = [] for h in tqdm(hits, disable=quiet): try: client.delete_hit(HITId=h["HITId"]) except Exception as e: client.update_expiration_for_hit(HITId=h["HITId"], ExpireAt=datetime(2015, 1, 1)) h["dispose_exception"] = e non_disposed_hits.append(h) return non_disposed_hits
def expire_and_dispose_hits( client: MTurkClient, hits: List[Dict[str, Any]]) -> List[Dict[str, Any]]: """ Loops over attempting to expire and dispose any hits in the hits list that can be disposed Returns any HITs that could not be disposed of """ non_disposed_hits = [] for h in hits: try: client.delete_hit(HITId=h["HITId"]) except: client.update_expiration_for_hit(HITId=h["HITId"], ExpireAt=datetime(2015, 1, 1)) non_disposed_hits.append(h) return non_disposed_hits