From cd1ede252fb9156e9220a1a4fba37b11bb6d6625 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Wed, 22 Jan 2020 19:07:07 +0100 Subject: [PATCH] Wip. Fix for unambiguous assignment id --- sorteerhoed/central_management.py | 3 ++- sorteerhoed/webserver.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sorteerhoed/central_management.py b/sorteerhoed/central_management.py index 97327f6..cb2734b 100644 --- a/sorteerhoed/central_management.py +++ b/sorteerhoed/central_management.py @@ -326,7 +326,8 @@ class CentralManagement(): sqsHit = self.currentHit updateStatus = True - sqsAssignment = sqsHit.getAssignmentById(signal.params['event']['AssignmentId']) + assId = signal.params['event']['AssignmentId'] + '_' + signal.params['event']['WorkerId'] + sqsAssignment = sqsHit.getAssignmentById(assId) if not sqsAssignment: self.logger.critical(f"Invalid assignmentId given for hit: {signal.params['event']}") continue diff --git a/sorteerhoed/webserver.py b/sorteerhoed/webserver.py index 14b691d..c6353f1 100644 --- a/sorteerhoed/webserver.py +++ b/sorteerhoed/webserver.py @@ -75,7 +75,10 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler): self.hit = self.store.currentHit + # my core assumption about assignment_id was wrong. It is not unique per worker, so we need to merge those self.assignment_id = str(self.get_query_argument('assignmentId')) + self.assignment_id += '_' + str(self.get_query_argument('workerId')) + self.assignment = self.hit.getLastAssignment() if self.assignment.assignment_id != self.assignment_id: @@ -317,6 +320,9 @@ class DrawPageHandler(tornado.web.RequestHandler): return assignmentId = self.get_query_argument('assignmentId', '') + if len(assignmentId): + assignmentId += '_' + str(self.get_query_argument('workerId', '')) + if len(assignmentId) < 1: logger.critical("Accessing page without assignment id. Allowing it for debug purposes... fingers crossed?")