diff --git a/tfw/components/frontend/message_queue_handler/message_queue_handler.py b/tfw/components/frontend/message_queue_handler/message_queue_handler.py index 3fbe07f..186caaf 100644 --- a/tfw/components/frontend/message_queue_handler/message_queue_handler.py +++ b/tfw/components/frontend/message_queue_handler/message_queue_handler.py @@ -8,23 +8,15 @@ class MessageQueueHandler: def __init__(self, wpm): self.connector = None - self._wpm, self._cps = None, None self.wpm = wpm self._queue = Queue() self._thread = Thread(target=self._dispatch_messages) - @property - def wpm(self): - return self._wpm - - @wpm.setter - def wpm(self, wpm): - self._wpm = wpm - self._cps = 5 * wpm / 60 - def _dispatch_messages(self): for message in iter(self._queue.get, None): - sleep(len(message['message'])/self._cps) + wpm = message['wpm'] if 'wpm' in message else self.wpm + cps = 5 * wpm / 60 + sleep(len(message['message']) / cps) self.connector.send_message(message) def handle_event(self, message, _):