Commits

Ernesto Menéndez  committed f9ea80f

..

  • Participants
  • Parent commits c2c6877

Comments (0)

Files changed (1)

File nxweb/apps/wmanws/worker_manager.py

     def offline(self, worker_token):
         """Called when a worker websocket connections is terminated"""
         worker = self.online_workers.get(worker_token)
+        if worker is None:
+            print "warning: tratando de desconectar un worker no existente"
+            return
+
         worker.disconnected()
 
         if self.online_workers.get(worker_token) is None:
             return "-".join(task)
 
         monitor_data = []
-        for (worker_token, worker) in self.online_workers.iteritems():
-            task_monitor = []
+        
+        try:
+            for (worker_token, worker) in self.online_workers.iteritems():
+                task_monitor = []
 
-            for task_comp_key in worker.assigned_tasks:
+                for task_comp_key in worker.assigned_tasks:
 
-                task = task_short_print(task_comp_key)
-                task_monitor.append(task)
-            if len(task_monitor)==0:
-                task_monitor = ""
-            else:
-                task_monitor = ",".join(task_monitor)
-            monitor_data.append({"worker_id":repr(worker.worker_number),
-                                 "worker_ip":worker.ip,
-                                 "assigned_tasks":task_monitor})
-        return monitor_data
+                    task = task_short_print(task_comp_key)
+                    task_monitor.append(task)
+                if len(task_monitor)==0:
+                    task_monitor = ""
+                else:
+                    task_monitor = ",".join(task_monitor)
+                monitor_data.append({"worker_id":repr(worker.worker_number),
+                                    "worker_ip":worker.ip,
+                                    "assigned_tasks":task_monitor})
+            return monitor_data
+        except:
+            return self.get_worker_monitor()
 
     def get_task_list_monitor(self):
         """Used to send the info to the monitors """