I am experiencing a very strange problem. I am able to submit a HIT to Amazon Mechanical Turk correctly. I have a cron that keeps checking if there is any job ready to be reviewed. However, when a job is completed I am not receiving it but the HIT is disposed (what is done inside the function to review it). The strange thing is that this problem is not happening always, but quite often.
This is the code of the function to review the HITs:
def self.review_hits
hits = RTurk::Hit.all_reviewable
p "HITS"
p hits
puts "REVIEWABLE HITS: " + hits.count.to_s
hits_results = {}
unless hits.empty?
hits.each do |hit|
puts "IN EACH HIT"
p hit
results = []
hit.expire!
# Get results for each HIT assignment
hit.assignments.each do |assignment|
# Check if the assignmment has been submitted. It can be the case where the maximum waiting time
# for the job to finish expired and there remain assignments that are not submitted
if assignment.status == 'Submitted'
p "STATUS 1"
p assignment.status
temp = {}
temp[:worker_id] = assignment.worker_id
temp[:answer] = assignment.answers
p "STATUS 2"
p assignment.status
assignment.approve!
results << temp
end
end
begin
hit.dispose!
rescue
end
hits_results[hit.id] = {}
hits_results[hit.id][:results] = results
end
# Let Rails know that there are new results
AmazonTurkHit.store_results(hits_results)
end
end
So the puts "REVIEWABLE HITS:" is 0 but the HIT is disposed. Does anyone know why?