mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 10:11:33 +00:00
Fix issues in PR #67
This commit is contained in:
parent
7a14928432
commit
af3781adb3
@ -11,7 +11,7 @@ class MessageQueueHandler:
|
||||
self._wpm, self._cps = None, None
|
||||
self.wpm = wpm
|
||||
self._queue = Queue()
|
||||
self._thread = Thread(target=self.dispatch_messages)
|
||||
self._thread = Thread(target=self._dispatch_messages)
|
||||
|
||||
@property
|
||||
def wpm(self):
|
||||
@ -20,19 +20,19 @@ class MessageQueueHandler:
|
||||
@wpm.setter
|
||||
def wpm(self, wpm):
|
||||
self._wpm = wpm
|
||||
self._cps = 5*wpm/60
|
||||
self._cps = 5 * wpm / 60
|
||||
|
||||
def dispatch_messages(self):
|
||||
def _dispatch_messages(self):
|
||||
for message in iter(self._queue.get, None):
|
||||
sleep(len(message['message'])/self._cps)
|
||||
self.connector.send_message(message)
|
||||
|
||||
def handle_event(self, message, _):
|
||||
for unpacked in self.generate_messages_from_queue(message):
|
||||
for unpacked in self._generate_messages_from_queue(message):
|
||||
self._queue.put(unpacked)
|
||||
|
||||
@staticmethod
|
||||
def generate_messages_from_queue(queue_message):
|
||||
def _generate_messages_from_queue(queue_message):
|
||||
last = queue_message['value'][-1]
|
||||
for message in queue_message['value']:
|
||||
yield {
|
||||
|
Loading…
Reference in New Issue
Block a user