Changes for stability

This commit is contained in:
Ruben van de Ven 2019-11-04 10:36:26 +01:00
parent 9b4e5d5c57
commit 19783efd57
2 changed files with 12 additions and 3 deletions

View file

@ -84,7 +84,7 @@ class HIT(Base):
return "accepted by worker" return "accepted by worker"
# on abandon: # on abandon:
if self.worker_id: if self.worker_id:
return "abandoned / awaiting worker" return "abandoned by worker"
return "awaiting worker" return "awaiting worker"
@ -166,7 +166,7 @@ class Store:
return self.getAvgDurationOfPreviousNHits(5) return self.getAvgDurationOfPreviousNHits(5)
def getHitTimeout(self): def getHitTimeout(self):
return max(200, self.getAvgDurationOfPreviousNHits(5)*2) return max(160, self.getAvgDurationOfPreviousNHits(5)*2)
def getHITs(self, n = 100): def getHITs(self, n = 100):
return self.session.query(HIT).\ return self.session.query(HIT).\

View file

@ -230,6 +230,7 @@ class CentralManagement():
sqsHit.submit_hit_at = datetime.datetime.utcnow() # fake submit sqsHit.submit_hit_at = datetime.datetime.utcnow() # fake submit
if updateStatus: if updateStatus:
self.setLight(False) self.setLight(False)
self.mturk.create_worker_block(WorkerId=signal.params['event']['WorkerId'], Reason='Accepted task without working on it.')
elif signal.name == 'sqs.AssignmentReturned': elif signal.name == 'sqs.AssignmentReturned':
self.logger.info(f'Set status progress to returned') self.logger.info(f'Set status progress to returned')
@ -251,6 +252,14 @@ class CentralManagement():
if sqsHit.uuid not in sqsHit.answer: if sqsHit.uuid not in sqsHit.answer:
self.logger.critical(f"Not a valid answer given?! {sqsHit.answer}") self.logger.critical(f"Not a valid answer given?! {sqsHit.answer}")
if not sqsHit.submit_page_at:
# page not submitted, hit is. Nevertheless, create new hit.
try:
self.mturk.reject_assignment(AssignmentId=signal.params['event']['AssignmentId'], RequesterFeedback='Did not do the assignment')
except Exception as e:
self.logger.exception(e)
self.makeHit()
else:
sqsHit.submit_hit_at = datetime.datetime.strptime(signal.params['event']['EventTimestamp'],"%Y-%m-%dT%H:%M:%SZ") sqsHit.submit_hit_at = datetime.datetime.strptime(signal.params['event']['EventTimestamp'],"%Y-%m-%dT%H:%M:%SZ")
self.store.saveHIT(sqsHit) self.store.saveHIT(sqsHit)