class WorkerSyslog:
    _worker_info = None

    def __init__(self, queue_worker, queue_result):
        self.queue_worker = queue_worker
        self.queue_result = queue_result
        self.socketSyslog = SocketSyslog((SERVER, PORT))
        self._stopevent = Event()
        self.msg = LogEvent()

    @property
    def worker_info(self):
        if self._worker_info is None:
            self._worker_info = self.queue_worker.get()
            print self._worker_info
        return self._worker_info

    def run(self):
        while not self._stopevent.isSet():
            self.ID = self.worker_info.get("ID")
            self.MSG_NUMBER = self.worker_info.get("MSG_NUMBER")
            self.MSG_TIMER = self.worker_info.get("MSG_TIMER")
            self.TIME_EXEC = 0

            currentTime = time()
            for i in xrange(self.MSG_NUMBER):
                # todo change msg syslog
                self.socketSyslog.log(self.msg.rand())
                sleep(self.MSG_TIMER)
            self.TIME_EXEC = time() - currentTime
            self.queue_result.put(
                {"TIME_EXEC": self.TIME_EXEC, "MSG_NUMBER": self.MSG_NUMBER, "MSG_TIMER": self.MSG_TIMER, "ID": self.ID}
            )
            self._worker_info = None

    def stopped(self):
        return self._stopevent.isSet()

    def stop(self):
        self._stopevent.set()
 def __init__(self, queue_worker, queue_result):
     self.queue_worker = queue_worker
     self.queue_result = queue_result
     self.socketSyslog = SocketSyslog((SERVER, PORT))
     self._stopevent = Event()
     self.msg = LogEvent()