- time.sleep(1)
- continue
-
- if task[0] == 'add':
- print self.name, ": processing task add mac", task[1]
- now=time.time()
- self.mac_status[task[1] ] = {"ip": None, "next_reading": now, "created": now, "retries":0}
- next_iteration = now
- elif task[0] == 'del':
- print self.name, ": processing task del mac", task[1]
- if task[1] in self.mac_status:
- del self.mac_status[task[1] ]
- elif task[0] == 'exit':
- print self.name, ": processing task exit"
- self.terminate()
- return 0
- else:
- print self.name, ": unknown task", task
+ task = None
+ self.queueLock.release()
+
+ if task is None:
+ now=time.time()
+ if now >= next_iteration:
+ next_iteration = self.get_ip_from_dhcp()
+ else:
+ time.sleep(1)
+ continue
+
+ if task[0] == 'add':
+ self.logger.debug("processing task add mac " + str(task[1]))
+ now=time.time()
+ self.mac_status[task[1] ] = {"ip": None, "next_reading": now, "created": now, "retries":0}
+ next_iteration = now
+ elif task[0] == 'del':
+ self.logger.debug("processing task del mac " + str(task[1]))
+ if task[1] in self.mac_status:
+ del self.mac_status[task[1] ]
+ elif task[0] == 'exit':
+ self.logger.debug("processing task exit")
+ self.terminate()
+ return 0
+ else:
+ self.logger.error("unknown task: " + str(task))
+ except Exception as e:
+ self.logger.critical("Unexpected exception at run: " + str(e), exc_info=True)